1.array_column to get a column in an array
$arrUsers=Array( Array( ' id ' = 1, ' name ' = ' Zhang San ', ' age ' = 25, ),Array( ' id ' = 2, ' name ' = ' John Doe ', ' age ' = 23, ),Array( ' id ' = 3, ' name ' = ' Harry ', ' age ' = 40, ),Array( ' id ' = 4, ' name ' = ' Zhao Liu ', ' age ' = 31, ),Array( ' id ' = 5, ' name ' = ' Yellow seven ', ' age ' = 20, ), ); Echo' <pre> '; Var_dump(Array_column ($arrUsers,name));Echo' </pre> ';
Output:
Array (5) { [0]=> string(6) "Zhang San" [1]=> string(6) "John Doe" [2]=> string(6) "Harry" [3]=> string(6) "Zhao Liu" [4]=> string(6) "Yellow Seven"}
2.array_combine () creates an array with the value of an array as the key and the value of the other array as
Header (' content-type:text/html; Charset=utf-8 '); $a Array (' id ', ' name ', ' phone ') ; $b=array(' 1 ', ' shenhuidong ', ' 12345 '); $c=array_combine($a$b); Print_r ($c); output: Array ([id] + 1 [name] = = Shenhuidong [phone] + 12345)
3.array_key_exists ($key, $array) determine if the key exists in the array
4.array_keys ($array) returns all the key names in the array
5.array_values ($array) returns all values in the array
6.array_merge ($arr 1, $arr 2) merging one or more arrays
7.array_multisort () sorting multiple or multidimensional arrays
8.array_search ($value, $array) searches the array for the given value and returns the corresponding key name if one exists.
PHP array functions