|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-10-28 07:44 UTC] krakjoe@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: krakjoe
[2013-10-28 07:44 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Jun 14 19:00:01 2026 UTC |
<? $array = array(array("a", "b"), array("c", "d")); foreach ($array[1] as $key=>$value) { echo "Foreach cycle: ", $key, "=>", $value, "\n"; } reset($array); // Resets only the external array // reset($array[1]); // Resets $array[1] itself while (list($key, $value) = each($array[1])) { echo "While cycle: ", $key, "=>", $value, "\n"; } ?> The internal pointer of $array[1] is at the end of the array, so no output will be produced from the second cycle. I have to reset($array[1]), if I want it to be reset. This is submitted once as a bug: http://bugs.php.net/bug.php?id=37 I agree that it's the right behaviour of reset(), but if I want to explicitely reset all the sub-arrays of an array, I have to write too complicated cycles + condition checks, for such a basic thing like this. It will be nice to have the option somewhere in the future (maybe as a second optional parameter) to reset all the internal arrays at once. ;)