I have these two numbers which are 4 and 4.5. i want both of it to be formatted as 04 and 04.50.
below is what i have done to display number 4 correctly.
$num_padded = sprintf("%02s", 4);
echo $num_padded;
but it doesn't work for 4.5
also if the no is 2 digit like 10 or 10.50 then no zero should be added. when value is 10.5 last zero must be added. how can i get a similar work done with PHP?
i found a similar answer here but not exactly what i am looking for. PHP prepend leading zero before single digit number, on-the-fly