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; echo $d; die; return ceil($n/10**$d) * 10**$d; } printf ("%d >> %d -- %d" . PHP_EOL, 1256, myRound(1256), round(1256, 2)); printf ("%d >> %d -- %d" . PHP_EOL, 1200.98, myRound(1200.98), round(1200.98, 2)); printf ("%d >> %d -- %d" . PHP_EOL, 138, myRound(138), round(138, 2)); printf ("%d >> %d -- %d" . PHP_EOL, 11.001, myRound(11.001), round(11.001, 2));
Show:  
Copy Clear