1
function nearest($num, $divisor) {
$diff = $num % $divisor;
if ($diff == 0)
return $num;
elseif ($diff >= ceil($divisor / 2))
return $num - $diff + $divisor;
else
return $num - $diff;
}
Call it like this:
<?php echo nearest(23647, 5000);?>