2019-02-27
array_keys()
array_keys ( array $array [, mixed $search_value = null [, bool $strict = false ]] ) : array
说明:获取数组中部分的或者所有的键名
$arr = [
'name' => 'ZhangSan',
'age' => 18,
'gender' => 'man',
];
print_r(array_keys($arr));
// output
Array
(
[0] => name
[1] => age
[2] => gender
)
array_map()
array_map ( callable $callback , array $array1 [, array $... ] ) : array
说明:为数组的每个元素应用回调函数
$arr = [1, 2, 6];
print_r(array_map(function($value){
return $value + 1;
}, $arr))
// output
Array
(
[0] => 2
[1] => 3
[2] => 7
)
array_merge()
array_merge ( array $array1 [, array $... ] ) : array
说明:合并一个或者多个数组
$arr = [1, 2, 6];
$arr2 = [2, 6, 7];
print_r(array_merge($arr, $arr2));
// output
Array
(
[0] => 1
[1] => 2
[2] => 6
[3] => 2
[4] => 6
[5] => 7
)
array_multisort()
array_multisort ( array &$array1 [, mixed $array1_sort_order = SORT_ASC [, mixed $array1_sort_flags = SORT_REGULAR [, mixed $... ]]] ) : bool
说明:对多个数组或者多维数组进行排序(具体可查看官网)
$data[] = array('volume' => 67, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 1);
$data[] = array('volume' => 85, 'edition' => 6);
$data[] = array('volume' => 98, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 6);
$data[] = array('volume' => 67, 'edition' => 7);
foreach ($data as $key => $value) {
$volume[$key] = $value['volume'];
$edition[$key] = $value['edition'];
}
array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);
print_r($data);
// output
Array
(
[0] => Array
(
[volume] => 98
[edition] => 2
)
[1] => Array
(
[volume] => 86
[edition] => 1
)
[2] => Array
(
[volume] => 86
[edition] => 6
)
[3] => Array
(
[volume] => 85
[edition] => 6
)
[4] => Array
(
[volume] => 67
[edition] => 2
)
[5] => Array
(
[volume] => 67
[edition] => 7
)
)
array_pop()
array_pop ( array &$array ) : mixed
说明:弹出数组中最后一个单元
$arr = [1, 2, 6];
array_pop($arr);
print_r($arr);
// output
Array
(
[0] => 1
[1] => 2
)
array_product()
array_product ( array $array ) : number
说明:计算数组中所有值的乘积
$arr = [1, 2, 6];
print_r(array_product($arr));
// output
12
之前因为一些事,就没有每天都更,以后会坚持保持每天都更
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。