note 16760 deleted from function.array-walk by jimw
| From: | jimw@php.net | Date: | Fri, 07 Dec 2001 01:42:22 +0000 |
| Subject: | note 16760 deleted from function.array-walk by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-21766@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.