3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function prettynum($num, $dollar = null) { global $mtgdb; $out = strrev((string) preg_replace('/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($num))); if($dollar && is_numeric($num)) { $out = "$" . $out; } return $out; } echo prettynum(123456)," "; echo prettynum(123456, 1);
Output for 4.3.0 - 7.1.0
123,456 $123,456