3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function f($s){ for( $i = $j = 0, $n = count( $s ) - 1; $j <= $n; ){ ( $s[$j] < 0 && ( ($x = $s[$i]) | ($s[$i] = $s[$j]) | ($s[$j] = $x) | $i++ | $j++ ) ) || ( $s[$j] && ( ($x = $s[$i]) | ($s[$i] = $s[$j]) | ($s[$j] = $x) | $n-- ) ) || $j++; } echo implode(',',$s); } echo "-------------\n"; f( [5, 3, 0, -6, 2, 0, 5] ); echo "-------------\n";
based on ebn74
Output for 5.4.0 - 7.2.0
------------- 5,3,0,-6,2,0,5-------------
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/HnISG on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[', expecting ')' in /in/HnISG on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/HnISG on line 12
Process exited with code 255.