note 37917 added to function.current

From: Date: Tue, 02 Dec 2003 07:10:00 +0000
Subject: note 37917 added to function.current
Groups: php.notes 
Request: Send a blank email to php-notes+get-61249@lists.php.net to get a copy of this message
Note that by copying an array its internal pointer is lost: <?php $myarray = array(0=>'a', 1=>'b', 2=>'c'); next($myarray); print_r(current($myarray)); echo '<br>'; $a = $myarray; print_r(current($a)); ?> Would output 'b' and then 'a' since the internal pointer wasn't copied. You can cope with that problem using references instead, like that: <?php $a =& $myarray; ?> ---- Manual Page -- http://www.php.net/manual/en/function.current.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37917 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37917&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37917&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61249) next »