3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function format_number($n) { $str = number_format($number, 4, '.', ''); $str = preg_replace('/(?<\.\d{2})0+$/', '', $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 5.0.4 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL
Output for 4.3.11 - 5.0.3
Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: preg_replace(): Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL
Output for 4.3.0 - 4.3.10
Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL Notice: Undefined variable: number in /in/GuU37 on line 4 Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/GuU37 on line 5 NULL