3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('nice_number')) { function nice_number($n) { // first strip any formatting; $n = (0 + str_replace(",", "", $n)); // is this a number? if (!is_numeric($n)) return false; // now filter it; $str = ''; if ($n > 1000000000000) { $str = round(($n / 1000000000000), 0) . ' tn '; $str .= $n % 1000000000000 > 0 ? nice_number($n % 1000000000000) : ''; return $str; } else if ($n > 1000000000) { $str = round(($n / 1000000000), 0) . ' bn '; $str .= $n % 1000000000 > 0 ? nice_number($n % 1000000000) : ''; return $str; } else if ($n > 1000000) { $str = round(($n / 1000000), 0) . ' mn '; $str .= $n % 1000000 > 0 ? nice_number($n % 1000000) : ''; return $str; } else if ($n > 1000) return round(($n / 1000), 2) . ' K '; return number_format($n); } } echo nice_number(3000000000);

preferences:
30.57 ms | 402 KiB | 5 Q