3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(1, 2, 3, 4, 5); print_r($a) $i = 0; for($i=0;$i<=4;$i++){ switch($i){ case 0: $rand=mt_rand(0,1); $b[]=$a[$rand]; break; case 1: if ($rand==0){ $b[]=$a[$rand+1]; else{ $b[]=$a[$rand-1]; } } break; case 2: $b[$i]=$a[2]; break; case 3: $rand=mt_rand(0,1); $b[]=$a[$rand]; break; case 4: if ($rand==0){ $b[]=$a[$rand+1]; else{ $b[]=$a[$rand-1]; } } break; } } print_r($b); ?>
Output for 5.4.0 - 5.4.21, 5.5.0 - 5.5.5
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/IUhrM on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE in /in/IUhrM on line 4
Process exited with code 255.

preferences:
185.74 ms | 1399 KiB | 63 Q