3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getFormattedNumber($n) { if($n<1000) return $n; $precision = 0; if($n < 1000000) { $m = $n/1000; if(is_float($m) AND $m<99) $precision = 1; var_dump($precision); return round($m, $precision, PHP_ROUND_HALF_DOWN).'K'; } $m = $n/1000000; if(is_float($m) AND $m<99) $precision = 1; var_dump($precision); return round($m, $precision, PHP_ROUND_HALF_DOWN).'M'; } echo getFormattedNumber(925926);
based on A9d6v
Output for 5.6.0 - 7.3.0beta1
int(0) 926K