PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function myRound($n) { $d = (int)log10($n) - 1; return ceil($n/10**$d) * 10**$d; } printf ("%d >> %d" . PHP_EOL, 1256, myRound(1256)); printf ("%d >> %d" . PHP_EOL, 1200.98, myRound(1200.98)); printf ("%d >> %d" . PHP_EOL, 138, myRound(138)); printf ("%d >> %d" . PHP_EOL, 11.001, myRound(11.001));
Show:  
Copy Clear