Get Percentage Function PHP

Sometimes we need to calculate the percentage of certain value in our project. In that circumstances you can use following PHP snippet to do that task.
PHP
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
echo get_percentage(10, 100); //usage function get_percentage($percentage, $of) { //courtesy : http://stackoverflow.com/a/14880194 $percent = $percentage / $of; return number_format( $percent * 100, 2 ) . '%';; }
New question is currently disabled!