ID: 32088 User updated by: karl at posmaster dot com dot au Reported By: karl at posmaster dot com dot au -Status: Feedback +Status: Open Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2005-02-28 New Comment:
- &$value is a refernce used in the foreach loop. - If the unset is commented out, the reference to $stuff[1] as $value on the second iteration of the loop works. - The call to unset() on the first iteration breaks the reference Actaul Output: array(1) { [1]=> string(3) "two" } Expected Output array(1) { [1]=> string(3) "This should appear below in the var_dump() because $value is passed by reference" } <?php $stuff = array('one','two'); foreach ($stuff as $key => &$value) { if($key==0){ unset ($stuff[$key]); }else{ $value='This should appear below in the var_dump() because $value is passed by reference'; } } var_dump($stuff); ?> Previous Comments: ------------------------------------------------------------------------ [2005-02-28 20:18:52] [EMAIL PROTECTED] What reference? Please give the _EXACT_ expected result. (and shorten the example script..) ------------------------------------------------------------------------ [2005-02-27 22:51:05] karl at posmaster dot com dot au No, the bug is still present. The reference that should be present is still broken. ------------------------------------------------------------------------ [2005-02-25 14:30:13] [EMAIL PROTECTED] So it's fixed and working -> closed. ------------------------------------------------------------------------ [2005-02-25 05:19:45] karl at posmaster dot com dot au Using that snapshot (PHP Version 5.0.4-dev) the second var_dump() produces: array(3) { [1]=> array(2) { [0]=> string(3) "one" [1]=> string(3) "two" } [3]=> array(2) { [0]=> string(4) "five" [1]=> string(3) "six" } [5]=> array(2) { [0]=> string(4) "nine" [1]=> string(3) "ten" } } Expecting: array(3) { [1]=> array(2) { [0]=> string(3) "one" [1]=> string(3) "foo" } [3]=> array(2) { [0]=> string(4) "five" [1]=> string(3) "foo" } [5]=> array(2) { [0]=> string(4) "nine" [1]=> string(3) "foo" } } Using Apache 1.3.31 PHP Configure string: './configure' '--prefix=/usr' '--disable-static' '--with-apxs=/usr/sbin/apxs' '--sysconfdir=/etc' '--enable-discard-path' '--with-config-file-path=/etc/apache' '--enable-safe-mode' '--with-openssl' '--with-mhash' '--enable-bcmath' '--with-bz2' '--with-pic' '--enable-calendar' '--enable-ctype' '--with-gdbm' '--with-db3' '--enable-dbase' '--enable-ftp' '--with-iconv' '--with-exif' '--with-gd' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png' '--with-gmp' '--with-gettext=shared,/usr' '--with-expat-dir=/usr' '--with-xml' '--enable-wddx' '--with-mm=/usr' '--enable-trans-sid' '--enable-shmop' '--enable-sockets' '--with-regex=php' '--enable-sysvsem' '--enable-sysvshm' '--enable-yp' '--enable-memory-limit' '--with-tsrm-pthreads' '--enable-shared' '--disable-debug' '--with-zlib=/usr' '--with-pgsql' '--with-mysql' ------------------------------------------------------------------------ [2005-02-24 23:50:30] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip I can't reproduce it. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/32088 -- Edit this bug report at http://bugs.php.net/?id=32088&edit=1