#18927 [Opn]: foreach corrupting array contents

From: Date: Thu, 15 Aug 2002 21:15:13 +0000
Subject: #18927 [Opn]: foreach corrupting array contents
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16941@lists.php.net to get a copy of this message
ID: 18927 User updated by: mattc@wselectric.com Reported By: mattc@wselectric.com Status: Open Bug Type: Scripting Engine problem Operating System: Slackware Linux 7.1.0 PHP Version: 4.2.2 New Comment: I originally experienced this problem on version 4.1.2 (same configure options), before upgrading -- only to find the problem still existed. Previous Comments: ------------------------------------------------------------------------ [2002-08-15 17:12:50] mattc@wselectric.com 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 this bug report at http://bugs.php.net/?id=18927&edit=1

« previous php.bugs (#16941) next »