#23701 [NEW]: optional parameter for reset() to reset all sub-arrays

From: Date: Mon, 19 May 2003 15:19:22 +0000
Subject: #23701 [NEW]: optional parameter for reset() to reset all sub-arrays
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39980@lists.php.net to get a copy of this message
From: kouber@php.net Operating system: Win2000NT PHP version: 4.3.2RC1 PHP Bug Type: Feature/Change Request Bug description: optional parameter for reset() to reset all sub-arrays <? $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. ;) -- Edit bug report at http://bugs.php.net/?id=23701&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23701&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23701&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23701&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23701&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23701&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23701&r=support Expected behavior: http://bugs.php.net/fix.php?id=23701&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23701&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23701&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23701&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23701&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23701&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23701&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23701&r=gnused

« previous php.bugs (#39980) next »