Array_map () functions a callback function on a given array cell
function
The function will return an array,
The array contains all the cells in the array1 after the callback action.
The number of arguments received by the callback callback function should be the same as the number of arrays passed to the Array_map () function.
"Scope of Use"
php4>4.0.6, PHP5.
Use
Array Array_map (callback Callback,array Arr1[,array ...])
callback/Required/user-supplied callback function as a comparison standard
arr1/an array of required/used comparisons
Array.../an array of selectable/used comparisons
Example
[PHP]
Defining callback Functions
function cube ($n) {
Return ($n * $n * $n);
}
$a =array (1,2,3,4,5);
$b =array_map ("Cube", $a);
Var_dump ($b);
/*
Array (5) {
[0]=>
Int (1)
[1]=>
Int (8)
[2]=>
Int (27)
[3]=>
Int (64)
[4]=>
Int (125)
}
*/
Excerpts from Zuodefeng's notes
http://www.bkjia.com/PHPjc/478214.html www.bkjia.com true http://www.bkjia.com/PHPjc/478214.html techarticle Array_map () functions a callback function on a given array cell "function" The function returns an array that contains all the cells in the Array1 that have been callback-worked ...