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!
- August 31, 2008
- article by Gabriel C.
- 2 comments
Related Posts
Calculating value from percentat August 31, 2008 with 4 comments
Create, Customize and Send Newsletters: MeeNewsat August 3, 2009 with 1 comment
PHP: Calculate the Size, Number of Files & Folders of a Directoryat September 24, 2008 with 3 comments

2 Replies to "Calculate percent from value"
May 12, 2010 at 10:31 AM
Hey thanks for that bit of code,nice post.
May 12, 2010 at 6:01 PM
Good for int’s but not good for floats, cant handle 29.99 etc