array_chunk
array_chunk — 将一个数组分割成多个
1 | $arr = ['a', 'b', 'c', 'd', 'e', 'f']; |
array_column
array_column — 返回数组中指定的一列
1 | $arr = [ |
array_combine
array_combine — 创建一个数组,用一个数组的值作为其键名,另一个数组的值作为其值
1 | $key = ['one', 'two', 'three']; |
array_count_values
1 | $array = array(1, "hello", 1, "world", "hello"); |
array_diff
array_diff — 计算数组的差集
1 | $array1 = array("a" => "green", "red", "blue", "red"); |
array_fill
array_fill — 用给定的值填充数组
1 | $a = array_fill(5, 6, 'banana'); |
array_filter
array_filter — 用回调函数过滤数组中的单元
1 | $arr = [1,2,3,4,6,7,8,9,10]; |
array_flip
array_flip — 交换数组中的键和值
1 | $input = array("oranges", "apples", "pears"); |
array_keys
array_keys — 返回数组中部分的或所有的键名
1 | $input = array("oranges", "apples", "pears"); |
array_map
array_map — 为数组的每个元素应用回调函数
1 | $input = array("oranges", "apples", "pears"); |
array_rand
array_rand — 从数组中随机取出一个或多个单元
1 | $input = array("oranges", "apples", "pears"); |
array_replace
array_replace — 使用传递的数组替换第一个数组的元素
1 | $base = array("orange", "banana", "apple", "raspberry"); |
array_slice
array_slice — 从数组中取出一段
1 | $base = array("orange", "banana", "apple", "raspberry"); |
arsort
arsort — 对数组进行逆向排序并保持索引关系
1 | $fruits = array("d" => "aemon", "a" => "brange", "b" => "canana", "c" => "dpple"); |
asort
asort — 对数组进行排序并保持索引关系
1 | $fruits = array("d" => "aemon", "a" => "brange", "b" => "canana", "c" => "dpple"); |
sort
sort — 对数组排序
1 |
|
list
list — 把数组中的值赋给一组变量
1 | $fruits = array("lemon", "orange", "banana", "apple"); |