3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $n = 5; $str = "-1 -14 5 -61 -2"; $e = ""; $m = "-"; $s = 0; for($i = 0, $len = strlen($str); $i < $len; $i++ ) { if(is_numeric($str[$i])) { $result[$s] .= $e . $str[$i]; } else { if($m == $str[$i]) { $e = $m; } else { $e = ""; $s++; } } } for($i = 0; $i < $n; $i++) { echo $result[$i] . "\n"; }
Output for 5.6.30, 7.0.0 - 7.2.9
Notice: Undefined variable: result in /in/0Xun0 on line 9 Notice: Undefined offset: 0 in /in/0Xun0 on line 9 Notice: Undefined offset: 1 in /in/0Xun0 on line 9 Notice: Undefined offset: 2 in /in/0Xun0 on line 9 Notice: Undefined offset: 3 in /in/0Xun0 on line 9 Notice: Undefined offset: 4 in /in/0Xun0 on line 9 -1 -1-4 5 -6-1 -2
Output for hhvm-3.15.4 - 3.22.0
-1 -1-4 5 -6-1 -2