note 54520 deleted from function.array-map by cmb
| From: | cmb@php.net | Date: | Sun, 29 Dec 2019 10:31:41 +0000 |
| Subject: | note 54520 deleted from function.array-map by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213686@lists.php.net to get a copy of this message | ||
Note Submitter: david dot tulloh at infaze dot com dot au
----
You can pass values to array_map by reference, essentially allowing you to use it as you would
array_walk with multiple arrays as parameters.
A trivial example:
<?php
$a = array(1,2,3,4,5);
$add_func = create_function('&$x, $y', '$x+=$y;');
array_map($add_func, $a, $a);
print_r($a);
?>
Array
(
[0] => 2
[1] => 4
[2] => 6
[3] => 8
[4] => 10
)