Hi i was wondering how i could remove the last 2 zero's as seen below:
13.6500
16.0000
17.5345
To the following:
13.65
16.00
17.5345
Hi i was wondering how i could remove the last 2 zero's as seen below:
13.6500
16.0000
17.5345
To the following:
13.65
16.00
17.5345
You can use round()
like this to round to 2 decimal points like this
echo round("13.6500",2);
Also you can use number_format()
like this
echo number_format("13.6500", 2);
Both yeilds the O/P
13.65
EDIT
from the comment i think what you want is like this
$input = "12.00000";
$length = strlen(substr(strrchr($input, "."), 1));
if($length > 2)
{
$input =$input+0;
if(strlen(substr(strrchr($input, "."), 1)) < 1)
{
$input = $input.".00";
}
else if(strlen(substr(strrchr($input, "."), 1)) < 2)
{
$input = $input.".0";
}
echo $input;
}
else
{
echo $input;
}