PHP 4.0 Bug #7578 Updated: next() and current() do not return referenceing arrays

From: Date: Thu, 02 Nov 2000 00:43:52 +0000
Subject: PHP 4.0 Bug #7578 Updated: next() and current() do not return referenceing arrays
Groups: php.dev 
Request: Send a blank email to php-dev+get-36729@lists.php.net to get a copy of this message
ID: 7578 Updated by: waldschrott Reported By: mog@linux.nu Status: Closed Bug Type: Arrays related Assigned To: Comments: you simply can´t do it that way, please read the manual on foreach() etc. and that additional "&" in > $array = array(&$array2); has absolutely no effect here, at least not what you expect it to do (please also read "references explained") > print next(current($array))."<br>"; // returns 1, correct > but the internal > pointer is only moved in the copy current() returned sure, current($array) returns a copy and thus all results you´ve mentioned are fine Previous Comments: --------------------------------------------------------------------------- [2000-11-01 19:29:27] mog@linux.nu i hope you can see what is wrong in the code below <?PHP $array2 = array(0,1,2); $array = array(&$array2); print current(current($array))."<br>"; // returns 0 print "<b>Try 1!</b><br>"; print next(current($array))."<br>"; // returns 1, correct but the internal pointer is only moved in the copy current() returned print current(current($array))."<br>"; // returns 0, wrong, should be 1 print current($array2)."<br>"; //returns 0, wrong, should be 1 print "<b>Try 2!</b><br>"; print next($array[0])."<br>"; print current(current($array))."<br>"; // returns 0, wrong, should be 1 print current($array[0])."<br>"; // returns 1, yes, correct! but the code above still didn't work! ?> --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7578

« previous php.dev (#36729) next »