array_map() 将回调函数作用到给定的数组单元上
【功能】
该函数将返回一个数组,
该数组包含了所有在array1中的所有单元经过callback作用过之后的单元。
callback回调函数接收的参数数目应该和传递给array_map()函数的数组数目一致。
【使用范围】
php4>4.0.6、php5.
【使用】
array array_map( callback callback,array arr1[,array...] )
callback/必需/为用户提供的作为比较标准的回调函数
arr1/必需/作比较的数组
array.../可选/作比较的数组
【示例】
[php]
//定义回调函数
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)
}
*/
摘自 zuodefeng的笔记
What are the definitions of arrays?
js string to array
Array initialization method
c array initialization method
How to find the maximum and minimum value of array elements in Java
How to remove the first few elements of an array in php
Summary of java basic knowledge
Zero-based Java self-study tutorial