Here is an incredibly short, sweet and simple php function that I use all of the time. This function provides you with a rounded percentage, base between two numbers:
<?php
function Get_Percent($number,$total)
{
$percentage = round($number * 100 / $total).”%”;
echo $percentage;
}
// Usage
echo “The percentage of people who came to my party was “.Get_Percent(19,23);
?>
For example, if I invited 23 friends to a party and only 19 turned up, to get the percentage I would use Get_Percent(19,23). This would parse as ‘83%’ – phew, I still have the majority in the real friends stake!
