Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP program to Calculate Percentage

// defining function
 function calPercentage($num, $total) {
  $count1 = $num_amount / $num_total;
  $count2 = $count1 * 100;
  $count = number_format($count2, 0);
  return $count;
}

// call function to calculate percentage
echo "Percentage of 100 in 1000 = ".calPercentage(100, 1000).'%<br/>';
echo "Percentage of 26 in 200 = ".calPercentage(26, 200).'%<br/>';
echo "Percentage of 30 in 400 = ".cal_percentage(30, 400).'%<br/>';

Output 
Percentage of 100 in 1000 = 10%
Percentage of 26 in 200 = 13%
Percentage of 30 in 400 = 8%
 
PREVIOUS NEXT
Tagged: #PHP #program #Calculate #Percentage
ADD COMMENT
Topic
Name
5+7 =