note 102456 modified in function.array-walk by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Feb 2011 13:55:48 +0000 |
| Subject: | note 102456 modified in function.array-walk by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177025@lists.php.net to get a copy of this message | ||
For completeness one has to mention the possibility of using this function with PHP 5.3 closures:
<?php
$names = array("D\'Artagnan", "Aramis", "Portos");
array_walk($names, function(&$n) {
$n = stripslashes($n);
});
?>
The trap with array_walk being it doesn't return the array, instead it's modified by
reference.
--was--
For completeness one has to mention the possibility of using this function with PHP 5.3 closures:
$names = array("D\'Artagnan", "Aramis", "Portos");
array_walk($names, function(&$n) {
$n = stripslashes($n);
});
The trap with array_walk being it doesn't return the array, instead it's modified by
reference.
http://php.net/manual/en/function.array-walk.php