Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?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));