xref: /PHP-8.2/Zend/tests/foreach_list_001.phpt (revision 5ebbdecf)
1--TEST--
2foreach with list syntax
3--FILE--
4<?php
5
6foreach(array(array(1,2), array(3,4)) as list($a, $b)) {
7    var_dump($a . $b);
8}
9
10$array = array(
11    array('a', 'b'),
12    array('c', 'd'),
13);
14
15foreach ($array as list($a, $b)) {
16    var_dump($a . $b);
17}
18
19
20$multi = array(
21    array(array(1,2), array(3,4)),
22    array(array(5,6), array(7,8)),
23);
24
25foreach ($multi as list(list($a, $b), list($c, $d))) {
26    var_dump($a . $b . $c . $d);
27}
28
29foreach ($multi as $key => list(list($a, $b), list($c, $d))) {
30    var_dump($key . $a . $b . $c . $d);
31}
32
33
34?>
35--EXPECT--
36string(2) "12"
37string(2) "34"
38string(2) "ab"
39string(2) "cd"
40string(4) "1234"
41string(4) "5678"
42string(5) "01234"
43string(5) "15678"
44