ID: 32959 Updated by: [EMAIL PROTECTED] Reported By: ben at bravenet dot com -Status: Closed +Status: Bogus Bug Type: Arrays related Operating System: Ubuntu Hoary 5.04 PHP Version: 4.3.10
Previous Comments: ------------------------------------------------------------------------ [2005-05-05 22:07:13] ben at bravenet dot com nm - just needed to read the manpage more carefully ------------------------------------------------------------------------ [2005-05-05 21:11:59] ben at bravenet dot com Description: ------------ After a foreach() on an array, key() won't return a value from the same array. It looks like an internal array pointer problem, since a reset() before key() appears to fix it. Reproduce code: --------------- <?php $foo = array('a'=>'1', 'b'=>'2', 'c'=>'3'); foreach($foo as $k=>$v) { echo "$k=>$v\n"; } // reset($foo); // this fixes the problem echo key($foo); ?> Expected result: ---------------- a=>1 b=>2 c=>3 a Actual result: -------------- a=>1 b=>2 c=>3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32959&edit=1