Copy CodeThe code is as follows:
/* function Array_map () function: Most group callback function---The function of the callback function to the cell of the given array
* 1, Syntax: Array Array_map (callback callback, array arr1 [, array ...])
* 2, Description: Returns an array that contains all the cells in the ARR1 after the callback action
Unit The number of arguments callback accepts should be the same as the number of arrays passed to the Array_map () function.
* 3. Precautions:
* 3.1. When the callback function of most groups is applied to an array, the key name of the original array is preserved, that is, the key name of the returned array is
* function to the given array of key names
* 3.2, most of the group back to function in two or more arrays, their length is consistent, and will ignore the original multiple array of
* Key name, uniform assigned numeric index as key name
*/
Examples of single array use
$websites =array ("g" = "google", "b" = "Baidu", "Y" and "Yahoo");
Output original Array
echo "
echo "
";
Defines a callback function for handling a single array
function Change_value ($value) {
Return Ucfirst ($value). ". COM ";
}
$urls =array_map (' Change_value ', $websites);
echo "
echo "
";
Examples of multiple arrays used
$arr 1=array (1,3,5,7);
$arr 2=array (2,4,6,8);
Defining callback functions for handling multiple arrays
function func1 ($a, $b) {
return $a * $b;
}
$results =array_map (' func1 ', $arr 1, $arr 2);
echo "Returns the result after processing multiple arrays using a callback function:
";
echo "
echo "
";
The results are as follows:
The above describes the ArrayList sort php array_map array functions using instructions, including the ArrayList sort of content, I hope that the PHP tutorial interested in a friend to help.