ID: 44965 Comment by: crrodriguez at suse dot de Reported By: yektaweb at gmail dot com Status: Open Bug Type: Arrays related Operating System: win xp PHP Version: 5.2.6 New Comment:
using key() and next() within variables involved in the foreach loop is an undefined operation. but anyway.. Do not file bugs when you have Zend extensions (zend_extension=) loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache, APC, Xdebug and ionCube loader. These extensions often modify engine behavior which is not related to PHP itself. Previous Comments: ------------------------------------------------------------------------ [2008-05-10 21:43:04] yektaweb at gmail dot com The following code will not affected by Zend Opt. foreach ($arr as $key => $value) { echo "Key: $key; Value: $value<br />\n"; } ------------------------------------------------------------------------ [2008-05-10 21:29:08] yektaweb at gmail dot com I am using Apache/2.2.0 Zend Optimizer v3.3.0 Zend SG Suite 3.1.0 ------------------------------------------------------------------------ [2008-05-10 21:22:05] yektaweb at gmail dot com Description: ------------ Zend affects on arrays (PHP Version 5.1.2) Reproduce code: --------------- <?php $fruits = array ("h" => "orange", "b" => "banana", "c" => "apple"); foreach ($fruits as $value) { $my_f = key($fruits); echo $my_f . '<br><br>'; next($fruits); } ?> Expected result: ---------------- h b c Actual result: -------------- b b c ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44965&edit=1