#18927 [NEW]: foreach corrupting array contents

From: Date: Thu, 15 Aug 2002 21:12:50 +0000
Subject: #18927 [NEW]: foreach corrupting array contents
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16940@lists.php.net to get a copy of this message
From: mattc@wselectric.com Operating system: Slackware Linux 7.1.0 PHP version: 4.2.2 PHP Bug Type: Scripting Engine problem Bug description: foreach corrupting array contents Running my sample script with the loop set up to 65534 times will run without corrupting the array $a. If you run it as 65535 times or more, the array is corrupted, and the value of $b becomes an array, which then causes the following warnings to be generated: PHP Warning: Illegal offset type in /home/web/dev/docs/lookup/bug.php on line 9 Obviously the foreach and array assignments should not be corrupting the contents of array $a. Sample script: <script language="php"> $a = array(1); foreach($a as $b) { for($c = 0; $c < 65535; $c++) { $d = 1; $e[$d][] = array($b, $c); $f[$b][$c][] = $d; } } </script> done Configure command: ./configure \ --with-mysql=/usr/local/mysql \ --with-apxs=/usr/local/apache/bin/apxs \ --enable-ftp \ --enable-track-vars \ --enable-versioning \ --with-zlib -- Edit bug report at http://bugs.php.net/?id=18927&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18927&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18927&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18927&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18927&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18927&r=support Expected behavior: http://bugs.php.net/fix.php?id=18927&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18927&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18927&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18927&r=globals

« previous php.bugs (#16940) next »