array_flip ( array $array ) : array
說明:交換數組中的鍵和值php
$arr = [ 'name' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; print_r(array_flip($arr)); // output Array ( [ZhangSan] => name [18] => age [man] => gender )
array_intersect_assoc ( array $array1 , array $array2 [, array $... ] ) : array
說明:帶索引檢查數組的交集數組
$arr1 = [ 'name' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; $arr2 = [ 'name' => 'ZhangSan', 'age1' => 18, 'gender' => 'woman', ]; print_r(array_intersect_assoc($arr1, $arr2)); // output Array ( [name] => ZhangSan )
`array_intersect_key ( array $array1 , array $array2 [, array $... ] ) : array
`
說明:使用鍵名計算數組的交集code
$arr1 = [ 'name' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; $arr2 = [ 'name' => 'ZhangSan', 'age1' => 18, 'gender' => 'woman', ]; print_r(array_intersect_key($arr1, $arr2)); // output Array ( [name] => ZhangSan [gender] => man )
array_intersect ( array $array1 , array $array2 [, array $... ] ) : array
說明:計算數組的交集索引
$arr1 = [ 'name1' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; $arr2 = [ 'name' => 'ZhangSan', 'age1' => 18, 'gender' => 'woman', ]; print_r(array_intersect($arr1, $arr2)); // output Array ( [name1] => ZhangSan [age] => 18 )
`array_key_exists ( mixed $key , array $array ) : bool
`
說明:檢查數組中是否含有指定的鍵名/索引ip
$arr1 = [ 'name1' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; print_r(array_key_exists('name1', $arr1)); // output boolean(true);