<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function percentage($x, $y, $precision) { // $precision define digit after the decimal point $result = round( ($x / $y) * 100, $precision ); return $result; } echo percentage(2, 3, 2); // This will print 66.67 echo percentage(2, 3, 0); // This will print 67 ?>
Thursday, June 27, 2013
PHP function to calculate percentage
6/27/2013
This post shows you how to calculate a percentage using a division and multiplying its result by 100. This is the simpliest way to calculate a percentage in PHP
Subscribe to:
Post Comments (Atom)
1 comments:
First of all I want to say excellent blog!
I had a quick question thast I'd like to ask if you don't mind.
I wwas interested to find out how you center yourself
and clear your thoughts prior to writing. I have had a hard time clearing my thoughts in getting my ideas out.
I truly do taie pleasurfe in writing but it just
seems like thee first 10 to 15 minutes tend too be wasted simply just trying
to figure out how to begin. Any ideas or hints?
Many thanks!
my web site :: web
Post a Comment