I have the following variable in PHP:
$number = 1714.2
As you can see with the last decimal I would like to add a 0 if the last decimal number is lower than 10.
What I would like my variable to look like:
1714.02
I have the following variable in PHP:
$number = 1714.2
As you can see with the last decimal I would like to add a 0 if the last decimal number is lower than 10.
What I would like my variable to look like:
1714.02
as .2 and .02 is not same. so, you must have to take correct value form source
or maybe php-manual number format is helpful to you. http://php.net/number_format
1714.2 is not equal to 1714.02 1714.2 means 1714.20 which means 1714.200
But if you want to get the desire result you want just put this code:
$number = $number - 0.18;
If you have a typo and you tried to say:
1714.2 being shown as 1714.20 then refer to: Set precision for a float number in PHP and number_format