ID: 35022 Updated by: [EMAIL PROTECTED] Reported By: stas at zend dot com -Status: Open +Status: Assigned Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS-2005-10-30 (CVS) -Assigned To: +Assigned To: iliaa
Previous Comments: ------------------------------------------------------------------------ [2005-10-30 12:38:22] [EMAIL PROTECTED] Analysis: this seems to be due to recent change by iliaa: http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.732&r2=1.733&ty=u and due to the following things: 1. key() is now declared as by-value function, so it takes argument via SEND_VAR 2. SEND_VAR separates references 3. separating uses zend_hash_copy 4. zend_hash_copy resets internal pointer ------------------------------------------------------------------------ [2005-10-30 12:36:32] stas at zend dot com Description: ------------ Consider the code below: it does not produce correct results on 4.4, 5.1 head, but worked in some 5.0 versions due to the fact that key() is defined as by-ref function in 5.0. Reproduce code: --------------- <? $state = array("one" => 1, "two" => 2, "three" => 3); function foo( &$state ) { $contentDict = end( $state ); for ( $contentDict = end( $state ); $contentDict !== false; $contentDict = prev( $state ) ) { echo key($state)."\n"; } } foo($state); ?> Expected result: ---------------- three two one Actual result: -------------- one one one ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35022&edit=1
