Array_map
("= 4.0.6, PHP 5" in PHP 4)
Array_map-array of considerations for various elements of callback
Description
Array array_map (callback $ callback, array $ arr1 [, array $...])
Array_map () returns all content contained in an array. The callback function after arr1 is applied to each object. The number of parameters for callback function acceptance should comply with several arrays passed to array_map ()
Parameters
Callback
Each array in each element of the callback function.
Arr1
A series of runtime callback functions.
Array
The variable parameter list array runs through the callback function.
Return value
Returns all the contents in an array. The callback function after arr1 is applied to each object.
Modify
Version description
5.3.0 now you can use the lambda function as the callback.
Instance
Example #1 array_map ()
<? Php
Function cube ($ n)
{
Return ($ n * $ n );
}
$ A = array (1, 2, 3, 4, 5 );
$ B = array_map ("cube", $ );
Print_r ($ B );
?>
This makes $ B have:
Array
(
[0] => 1
[1] => 8
[2] => 27
[3] => 64
[4] = & gt; 125
)