Bug #53725 [NEW]: array was changed
| From: | Nikolay dot Syrisko at gmail dot com | Date: | Wed, 12 Jan 2011 13:20:46 +0000 |
| Subject: | Bug #53725 [NEW]: array was changed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-157850@lists.php.net to get a copy of this message | ||
From:
Operating system: windows 7
PHP version: 5.2.17
Package: *General Issues
Bug Type: Bug
Bug description:array was changed
Description:
------------
when I declare array and make foreach
step 1: foreach ($list as &$rec) {
then make
step 2: foreach ($list as $rec) {
and last element of $list at the moment "step 1" will broken after
executing of "step 2" with data of last element of $list at the moment
"step 2"
ps: checked under different versions including 5.2.17
when you make unset($rec) before calling "step 2" bug will not appear.
Test script:
---------------
$list = array(1, 2, 3, 4, 5);
foreach($list as &$rec);
echo '<pre>'.print_r($list, 1).'</pre>';
$list[] = 6;
$list[] = 7;
foreach($list as $rec);
echo '<pre>'.print_r($list, 1).'</pre>';
--
Edit bug report at http://bugs.php.net/bug.php?id=53725&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53725&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53725&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53725&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53725&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53725&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53725&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53725&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53725&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53725&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53725&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53725&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53725&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53725&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53725&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53725&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53725&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53725&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53725&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53725&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53725&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53725&r=mysqlcfg