@ 2014-02-01T08:03:37Z <?php
$array = [
[1, 2],
[3, 4],
];
foreach ($array as list($a, $b)) {
// $a contains the first element of the nested array,
// and $b contains the second element.
echo "A: $a; B: $b\n";
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.34 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 A: 1; B: 2
A: 3; B: 4
Output for 5.4.0 - 5.4.45 Parse error: syntax error, unexpected 'list' (T_LIST) in /in/HO9H8 on line 7
Process exited with code 255 . Output for 5.3.0 - 5.3.29 Parse error: syntax error, unexpected '[' in /in/HO9H8 on line 2
Process exited with code 255 . preferences:dark mode live preview
254.74 ms | 401 KiB | 410 Q