3v4l.org

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

preferences:
181.14 ms | 1395 KiB | 57 Q