Php-Arrays function-array_map-applies the callback function to the unit of the given array. Array_map () calls the callback function to a given array unit. [function] This function returns an array that contains all the units in array1. after callback, the callback function acts as array_map () calls the callback function to a given array unit.
[Function]
This function returns an array,
This array contains all units in array1 that have passed the callback function.
The number of parameters received by the 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, array arr1 [, array...])
Callback/required/provided by the user as a standard callback function
Arr1/required/comparative array
Array.../optional/array for comparison
[Example]
[Php]
// Define the callback function
Function cube ($ n ){
Return ($ n * $ n );
}
$ A = array (1, 2, 3, 4, 5 );
$ B = array_map ("cube", $ );
Var_dump ($ B );
/*
Array (5 ){
[0] =>
Int (1)
[1] =>
Int (8)
[2] =>
Int (27)
[3] =>
Int (64)
[4] =>
Int (125)
}
*/
Taken from zuodefeng's note
Http://www.bkjia.com/PHPjc/478214.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478214.htmlTechArticlearray_map () calls the callback function to a given array unit [function] This function returns an array that contains all units in array1 that have passed through callback...