好了下面我們來看看php array_intersect_ukey()函數使用方法與執行個體教程吧.
array_intersect_ukey()定義和用法
該array_intersect_ukey ( )函數比較的鑰匙在兩個或兩個以上的陣列,檢查比賽之前,比較的鑰匙在一個使用者定義的函數,然後返回一個數組的項和值從第一個數組,如果該功能允許它。
文法
array_intersect_ukey(array1,array2,array3...,function)
| Parameter |
Description |
| array1 |
Required. The first array is the array that the others will be compared with |
| array2 |
Required. An array to be compared with the first array |
| array3 |
Optional. An array to be compared with the first array |
| function |
Required. The name of the user-made function |
提示和說明
提示:您可以比較的第一個陣列一個陣列,或有你喜歡。
注意:只有鑰匙必須同時獲得一場比賽,無論是在自動對比和使用者定義的函數。
範例1
<?phpfunction myfunction($v1,$v2) {if ($v1===$v2){return 0;}if ($v1>$v2){return 1;}else{return -1;}}$a1=array(0=>"Dog",1=>"Cat",2=>"Horse");$a2=array(3=>"Rat",1=>"Bird",5=>"Monkey");print_r(array_intersect_ukey($a1,$a2,"myfunction"));?>
輸出結果.
Array ( [] => Cat )