Asked 30+ days ago
15 Dec 2017
Views 106

jabber posted

how to get percentage of value in php ?

i want to get percentage of value like i have 12345 total amount and 1200 amount is how much percentage of 12345 ?

$percent='';//want to find percentage

i trying following solution . but its not getting percentage

$percentInDecimal = $data1 / 100;
//Get the result.
$percent = $percentInDecimal * $dataofdata1;
//Print it out - Result is 232.
echo $percent;

Mitul Dabhi

Mitul Dabhi
answered Jan 21 '18 20:17

$totalvalue is 100 percentage than how much percentage for $someofvalue ?

so multiply $someofvalue to 100 and divide it with $totalvalue

so equation is like =($someofvalue*100)/$totalvalue;


//round it 
echo round($percent);

Edit Answer
Post Answer