3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function format_number($number) { $str = number_format($number, 4, '.', ''); $str = preg_replace('/(?<=\.\d{2,3})0+$/', '', $str); return $str; } var_dump(format_number(4.0)); var_dump(format_number(4.5)); var_dump(format_number(4.454)); var_dump(format_number(4.54545454)); var_dump(format_number(4.450));
Output for 4.3.11 - 5.6.28, 7.0.0 - 7.1.0
Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: preg_replace(): Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL
Output for 4.3.0 - 4.3.10, hhvm-3.10.0 - 3.13.2
Warning: Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL Warning: Compilation failed: lookbehind assertion is not fixed length at offset 13 in /in/OFk2b on line 5 NULL