how can i shorten a long number with php ? So a number like 0.3483748937847832 would become 0.34
Asked
Active
Viewed 498 times
0
-
http://stackoverflow.com/questions/4371059/shorten-long-numbers-to-k-m-b – underscore Jun 16 '13 at 03:22
2 Answers
1
Please search stackoverflow first - from PHP: show a number to 2 decimal places
return number_format((float)$number, 2, '.', '');
https://stackoverflow.com/a/4483561/689579
or
$padded = sprintf('%0.2f', $unpadded); // 520 -> 520.00