【PHP 每日函数】第 02 周期
2019 - 02 - 22
array_flip()
array_flip ( array $array ) : array
说明:交换数组中的键和值
$arr = [ 'name' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; print_r(array_flip($arr)); // output Array ( [ZhangSan] => name [18] => age [man] => gender )
array_intersect_assoc()
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_intersect_key ( array $array1 , array $array2 [, array $... ] ) : array
`
说明:使用键名计算数组的交集
$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_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()
`array_key_exists ( mixed $key , array $array ) : bool
`
说明:检查数组中是否含有指定的键名/索引
$arr1 = [ 'name1' => 'ZhangSan', 'age' => 18, 'gender' => 'man' ]; print_r(array_key_exists('name1', $arr1)); // output boolean(true);
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23