1. Array_fill (Index,number,value) fills an array with values
Parameter description:
Index: The first index value of the returned array
Number: Specifies how many elements to insert
Value: The values used to populate the array
<?php$a1=array_fill (3,4, "blue");p Rint_r ($a 1);? >
Operation Result:
Array ([3] = blue [4] = blue [5] = = Blue [6] = blue)
2, Array_combine ($keys, $values) merging arrays
Parameter description:
$keys: Key an array group
$values: Array of key values
<?php$fname=array ("Bill", "Steve", "Mark"), $age =array ("" "," "" "]," "" "), $c =array_combine ($fname, $age);p Rint_r ($ c);? >
Operation Result:
Array ([Bill] [Steve] = [Mark] + 31)
3, Array_intersect_key ($arr 1, $arr 2, $arr 3 ...) Compares the key names of two or more arrays, returning the intersection
<?php$a1=array ("A" and "Red", "b" = "green", "c" = "blue"), $a 2=array ("a" and "Red", "c" = "Blue", "d" = > "Pink"); $result =array_intersect_key ($a 1, $a 2);p Rint_r ($result);? >
return Result:
Array ([A] = red [c] = blue)
4. Array_shift ($arr) deletes the first element in the array and returns the deleted element
<?php$a=array ("A" and "Red", "b" = "green", "C" and "Blue"); Echo array_shift ($a);p rint_r ($a);? >
return Result:
Redarray ([b] = green [c] = blue)
5, Array_walk ($arr, function ($value, $key) {}) functions apply a callback function to each element in the array
Changing the values in the array requires a reference type & $value
<?phpfunction myfunction (& $value, $key) {$value = "yellow";} $a =array ("a" and "Red", "b" = "green", "c" = "blue"), Array_walk ($a, "myfunction");p Rint_r ($a); >
return Result:
Array ([A] = yellow [b] = yellow [c] = yellow)
PHP Common array functions (1)