PHP 4.0 Bug #4999: foreach() does not act like each(), uses a copy

From: Date: Tue, 13 Jun 2000 06:52:32 +0000
Subject: PHP 4.0 Bug #4999: foreach() does not act like each(), uses a copy
Groups: php.dev 
Request: Send a blank email to php-dev+get-21181@lists.php.net to get a copy of this message
From: waldschrott@kiffen.de Operating system: win2000/all PHP version: 4.0 Latest CVS (13/06/2000) PHP Bug Type: Documentation problem Bug description: foreach() does not act like each(), uses a copy It should be documented that foreach() uses a copy of the passed array, being completely independent from the original $a - for the reason that each() (and next() and so on) works directly on the arrays pointer <?php $a=array(0,1,2,3,4,5,6); foreach ($a AS $val) { print $val; list(,$val)=each($a); list(,$val)=each($a); next($a); print $val; } ?>

« previous php.dev (#21181) next »