I want to add .00 to my value.
For example:
100 will be 100.00
100.26 will be 100.26 only.
number_format() can be your friend
you can use
round()
or
number_format()
Like @Gaurav said, use the number_format()
function. Simply pass it the value and the number of digits you want there to be after the decimal point:
$value = 100;
echo number_format($value, 2); //prints "100.00"
Note that by default, it will also insert commas as the thousands separator:
$value = 2013;
echo number_format($value, 2); //prints "2,013.00"
You can change the characters that are used as the decimal point and thousands separator by passing them in as the third and fourth parameters to the function:
$value = 2013;
echo number_format($value, 2, ',', ' '); //prints "2 013,00"
number_format(100, 2, '.', ' ')
$YOUR_VALUE = 1000.25;
echo number_format($YOUR_VALUE, 2);