1--TEST-- 2SPL: ArrayIterator 3--INI-- 4allow_call_time_pass_reference=1 5--FILE-- 6<?php 7 8echo "==Normal==\n"; 9 10$arr = array(0=>0, 1=>1, 2=>2); 11$obj = new ArrayObject($arr); 12 13foreach($obj as $ak=>$av) { 14 foreach($obj as $bk=>$bv) { 15 if ($ak==0 && $bk==0) { 16 $arr[0] = "modify"; 17 } 18 echo "$ak=>$av - $bk=>$bv\n"; 19 } 20} 21 22echo "==UseRef==\n"; 23 24$arr = array(0=>0, 1=>1, 2=>2); 25$obj = new ArrayObject(&$arr); 26 27foreach($obj as $ak=>$av) { 28 foreach($obj as $bk=>$bv) { 29 if ($ak==0 && $bk==0) { 30 $arr[0] = "modify"; 31 } 32 echo "$ak=>$av - $bk=>$bv\n"; 33 } 34} 35 36echo "==Modify==\n"; 37 38$arr = array(0=>0, 1=>1, 2=>2); 39$obj = new ArrayObject(&$arr); 40 41foreach($obj as $ak=>$av) { 42 foreach($obj as $bk=>$bv) { 43 if ($ak==0 && $bk==0) { 44 $arr[0] = "modify"; 45 } 46 echo "$ak=>$av - $bk=>$bv\n"; 47 } 48} 49 50echo "==Delete==\n"; 51 52$arr = array(0=>0, 1=>1, 2=>2); 53$obj = new ArrayObject(&$arr); 54 55foreach($obj as $ak=>$av) { 56 foreach($obj as $bk=>$bv) { 57 if ($ak==1 && $bk==1) { 58 unset($arr[1]); 59 } 60 echo "$ak=>$av - $bk=>$bv\n"; 61 } 62} 63 64echo "==Change==\n"; 65 66$arr = array(0=>0, 1=>1, 2=>2); 67$obj = new ArrayObject(&$arr); 68 69foreach($obj as $ak=>$av) { 70 foreach($obj as $bk=>$bv) { 71 if ($ak==1 && $bk==1) { 72 $arr = NULL; 73 } 74 echo "$ak=>$av - $bk=>$bv\n"; 75 } 76} 77 78echo "Done\n"; 79?> 80--EXPECTF-- 81==Normal== 820=>0 - 0=>0 830=>0 - 1=>1 840=>0 - 2=>2 851=>1 - 0=>0 861=>1 - 1=>1 871=>1 - 2=>2 882=>2 - 0=>0 892=>2 - 1=>1 902=>2 - 2=>2 91==UseRef== 920=>0 - 0=>0 930=>0 - 1=>1 940=>0 - 2=>2 951=>1 - 0=>modify 961=>1 - 1=>1 971=>1 - 2=>2 982=>2 - 0=>modify 992=>2 - 1=>1 1002=>2 - 2=>2 101==Modify== 1020=>0 - 0=>0 1030=>0 - 1=>1 1040=>0 - 2=>2 1051=>1 - 0=>modify 1061=>1 - 1=>1 1071=>1 - 2=>2 1082=>2 - 0=>modify 1092=>2 - 1=>1 1102=>2 - 2=>2 111==Delete== 1120=>0 - 0=>0 1130=>0 - 1=>1 1140=>0 - 2=>2 1151=>1 - 0=>0 1161=>1 - 1=>1 117 118Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_004.php on line %d 1191=>1 - 0=>0 1201=>1 - 2=>2 121 122Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_004.php on line %d 1230=>0 - 0=>0 1240=>0 - 2=>2 1252=>2 - 0=>0 1262=>2 - 2=>2 127==Change== 1280=>0 - 0=>0 1290=>0 - 1=>1 1300=>0 - 2=>2 1311=>1 - 0=>0 1321=>1 - 1=>1 133 134Notice: main(): ArrayIterator::current(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d 135 136Notice: main(): ArrayIterator::valid(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d 137 138Notice: main(): ArrayIterator::current(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d 139 140Notice: main(): ArrayIterator::valid(): Array was modified outside object and is no longer an array in %sarray_004.php on line %d 141Done 142