1--TEST-- 2Bug #16227 (Internal hash position bug on assignment) 3--FILE-- 4<?php 5// reported by php.net@alienbill.com 6$arrayOuter = array("key1","key2"); 7$arrayInner = array("0","1"); 8 9print "Correct - with inner loop reset.\n"; 10 11while(list(,$o) = each($arrayOuter)){ 12 reset($arrayInner); 13 while(list(,$i) = each($arrayInner)){ 14 print "inloop $i for $o\n"; 15 } 16} 17reset($arrayOuter); 18reset($arrayInner); 19 20print "What happens without inner loop reset.\n"; 21 22while(list(,$o) = each($arrayOuter)){ 23 while(list(,$i) = each($arrayInner)){ 24 print "inloop $i for $o\n"; 25 } 26} 27reset($arrayOuter); 28reset($arrayInner); 29 30print "What happens without inner loop reset but copy.\n"; 31 32while(list(,$o) = each($arrayOuter)){ 33 $placeholder = $arrayInner; 34 while(list(,$i) = each($arrayInner)){ 35 print "inloop $i for $o\n"; 36 } 37} 38reset($arrayOuter); 39reset($arrayInner); 40 41print "What happens with inner loop reset over copy.\n"; 42 43while(list(,$o) = each($arrayOuter)){ 44 $placeholder = $arrayInner; 45 while(list(,$i) = each($placeholder)){ 46 print "inloop $i for $o\n"; 47 } 48} 49reset($arrayOuter); 50reset($arrayInner); 51?> 52--EXPECT-- 53Correct - with inner loop reset. 54inloop 0 for key1 55inloop 1 for key1 56inloop 0 for key2 57inloop 1 for key2 58What happens without inner loop reset. 59inloop 0 for key1 60inloop 1 for key1 61What happens without inner loop reset but copy. 62inloop 0 for key1 63inloop 1 for key1 64inloop 0 for key2 65inloop 1 for key2 66What happens with inner loop reset over copy. 67inloop 0 for key1 68inloop 1 for key1 69inloop 0 for key2 70inloop 1 for key2 71