Annotation of embedaddon/php/ext/spl/tests/array_008.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: ArrayIterator and foreach reference
3: --INI--
4: allow_call_time_pass_reference=1
5: --FILE--
6: <?php
7:
8: echo "==Normal==\n";
9:
10: $arr = array(0=>0, 1=>1, 2=>2);
11: $obj = new ArrayObject($arr);
12:
13: foreach($obj as $ak=>&$av) {
14: foreach($obj as $bk=>&$bv) {
15: if ($ak==0 && $bk==0) {
16: $bv = "modify";
17: }
18: echo "$ak=>$av - $bk=>$bv\n";
19: }
20: }
21:
22: echo "==UseRef==\n";
23:
24: $arr = array(0=>0, 1=>1, 2=>2);
25: $obj = new ArrayObject(&$arr);
26:
27: foreach($obj as $ak=>&$av) {
28: foreach($obj as $bk=>&$bv) {
29: if ($ak==0 && $bk==0) {
30: $bv = "modify";
31: }
32: echo "$ak=>$av - $bk=>$bv\n";
33: }
34: }
35:
36: ?>
37: ===DONE===
38: <?php exit(0); ?>
39: --EXPECTF--
40: ==Normal==
41: 0=>modify - 0=>modify
42: 0=>modify - 1=>1
43: 0=>modify - 2=>2
44: 1=>1 - 0=>modify
45: 1=>1 - 1=>1
46: 1=>1 - 2=>2
47: 2=>2 - 0=>modify
48: 2=>2 - 1=>1
49: 2=>2 - 2=>2
50: ==UseRef==
51: 0=>modify - 0=>modify
52: 0=>modify - 1=>1
53: 0=>modify - 2=>2
54: 1=>1 - 0=>modify
55: 1=>1 - 1=>1
56: 1=>1 - 2=>2
57: 2=>2 - 0=>modify
58: 2=>2 - 1=>1
59: 2=>2 - 2=>2
60: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>