round() function is used for decimal like 5,5 -> 6 and 5,3 -> 5, and i have problem with milion numbers. For Example : i have number like 35000001, how to make that number to be 3500000 and 69999 to be 70000
Asked
Active
Viewed 3,583 times
2
-
2you can try rounding your number/10 and multiply the result by 10 – Sep 15 '14 at 08:28
-
http://stackoverflow.com/questions/5834537/how-to-round-down-to-the-nearest-significant-figure-in-php The answers to this question should help you. – Simon Brahan Sep 15 '14 at 08:30
2 Answers
2
$a = round($a / 10) * 10
You can change 10 to be 100, 1000, etc in order to round to a bigger degree.

Mihai Scurtu
- 1,448
- 1
- 11
- 22
1
Take a look at the round
function in the PHP manual:
<?php
echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?>
Perhaps what you want is:
echo round(1241757, -3); // 1242000

PinoyPal
- 388
- 3
- 12