3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $number = 13000000; // Here's the function function formatter ($number) { $bil = floor ($number / 1000000000); $millions = $number % 1000000000; $mil = floor ($millions / 1000000); $thousands = $millions % 1000000; $thou = floor ($thousands / 1000); $str = ''; if ($bil != 0) { $str .= "{$bil} billions "; } if ($mil != 0) { $str .= "{$mil} millions "; } if ($thou != 0) { $str .= "{$thou} thousands "; } echo $str; }
based on l9YJ0
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0