3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(1, 2, 3, 4, 5); print_r($a) $b=array(); $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
Parse error: syntax error, unexpected '$b' (T_VARIABLE) in /in/b0un8 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/b0un8 on line 4
Process exited with code 255.

preferences:
177.11 ms | 1395 KiB | 57 Q