PHP: Calculate the percentage of a number.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
//My number is 928.
$myNumber = 928;
 
//I want to get 25% of 928.
$percentToGet = 25;
 
//Convert our percentage value into a decimal.
$percentInDecimal = $percentToGet / 100;
 
//Get the result.
$percent = $percentInDecimal * $myNumber;
 
//Print it out - Result is 232.
echo $percent;

Comments

Popular posts from this blog

Xampp MySQL not starting

Multiple Login in Google Talk!