note 116929 deleted from function.array-filter by tularis
| From: | tularis@php.net | Date: | Mon, 23 Mar 2015 13:41:33 +0000 |
| Subject: | note 116929 deleted from function.array-filter by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202014@lists.php.net to get a copy of this message | ||
Note Submitter: PHPguru
----
Caution: If the array is changed from the callback function (e.g. element added, deleted or unset)
the behavior of this function is undefined.
I tested this with PHP 5.5.3.
$test = array(0,1,2,3,4,);
$test2 = array_filter($test, function($value) {
global $test;
unset($test[$value]);
return $value;
});
print_r($test);
print_r($test2);
And here was the result:
Array ( ) Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 )