foreach() using current() strange beahvior

From: Date: Sat, 23 Jun 2007 17:15:45 +0000
Subject: foreach() using current() strange beahvior
Groups: php.general 
Request: Send a blank email to php-general+get-257710@lists.php.net to get a copy of this message
Please consider this code : <?php $a = array("One","Two","Three"); foreach ($a AS $k=>$v) { } var_dump(current($a)); // outputs boll(false); that's expected as foreach moves the internal array pointer, it's documented. now consider this : <?php $a = array("One","Two","Three"); foreach ($a AS $k=>$v) { current($a); } var_dump(current($a)); // outputs string("One"); When using the internal pointer just by calling current() (so not moving it), the output of the foreach loop has changed ... Can someone explain that ? regards.

« previous php.general (#257710) next »