Calculate percent from value

Posted on August 31, 2008, Filled under PHP,  Bookmark it

Here’s how you can calculate the percent from a value.

<?php
/* Credits: http://www.bitrepository.com */

// example: number of employees in a company's department (Marketing)
$value = '20';
// total employees that company has
$total = '500'; 

$percent = number_format(($value * 100) / $total);

// percent of employees from the Marketing Department.
echo $percent.'%';
?>

Do you wish to receive the latest updates as soon as they are posted? Get our RSS Feed or Subscribe to the Newsletter!

Get our RSS Feed!

Sponsors

Related Posts

Leave a Reply


* = required fields

(will not be published)


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


  

CommentLuv Enabled