note 16760 added to function.array-walk

From: Date: Mon, 12 Nov 2001 16:26:28 +0000
Subject: note 16760 added to function.array-walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-20759@lists.php.net to get a copy of this message
Altering the contents of the array itself in the midst of array_walk is likely to lead to unpredictable results. EG #1 array_walk(&$myarr, "myfunc"); function myfunc(&$value, $key) { global $myarr; $myarr=null; } Destructively altering the variable that actually holds the array, as above, will most likely crash PHP. #2 (hypothesis) If you delete item N while array_walk is "visiting" item M, and N has not yet been visited, that's likely to do weird things. It probably *SHOULD* be documented that you can only alter the current item being visited in an array_walk, or some similar statement. -- http://www.php.net/manual/en/function.array-walk.php http://master.php.net/manage/user-notes.php?action=edit+16760 http://master.php.net/manage/user-notes.php?action=delete+16760 http://master.php.net/manage/user-notes.php?action=reject+16760

« previous php.notes (#20759) next »