PHP 每日函式 第 02 週期

2021-09-12 18:17:28 字數 1992 閱讀 7327

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 $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

`說明:使用鍵名計算陣列的交集

$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

`說明:檢查陣列中是否含有指定的鍵名/索引

$arr1 = [

'name1' => 'zhangsan',

'age' => 18,

'gender' => 'man'

];print_r(array_key_exists('name1', $arr1));

// output

boolean(true);

PHP 每日函式 第 02 週期

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 arra...

PHP 每日函式 第 02 週期

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 arra...

PHP 每日函式 第 02 週期

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 arra...