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--EXPECTF-- 53Correct - with inner loop reset. 54 55Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d 56inloop 0 for key1 57inloop 1 for key1 58inloop 0 for key2 59inloop 1 for key2 60What happens without inner loop reset. 61inloop 0 for key1 62inloop 1 for key1 63What happens without inner loop reset but copy. 64inloop 0 for key1 65inloop 1 for key1 66inloop 0 for key2 67inloop 1 for key2 68What happens with inner loop reset over copy. 69inloop 0 for key1 70inloop 1 for key1 71inloop 0 for key2 72inloop 1 for key2 73