function array_uintersect_uassoc() na kiyaye kwayewa da kuma kwayewa (tana da kuma yawa) sabonin alamari
sauki
kaɗa kwayewa da kuma kwayewa (amfani da labari na mutum don kiyaye) kuma ta kammala da kwayewa (kuma):
<?php function myfunction_key($a,$b) { if ($a===$b) { return 0; } return ($a>$b)?1:-1; } function myfunction_value($a,$b) { if ($a===$b) { return 0; } return ($a>$b)?1:-1; } $a1=array("a"=>"red","b"=>"green","c"=>"blue"); $a2=array("a"=>"red","b"=>"green","c"=>"green"); $result=array_uintersect_uassoc($a1,$a2,"myfunction_key","myfunction_value"); print_r($result); ?>
tafida da amfani
function array_uintersect_uassoc() na kiyaye kwayewa da kuma kwayewa (tana da kuma yawa) sabonin alamari, kuma ta kammala da kwayewa.
sauti:ta amfani da labari na mutum biyu don kiyaye; na farko yana kiyaye kwayewa, na biyu yana kiyaye kwayewa!
ta mayar da nau'ikan (tana da kuma yawa) sabonin alamari, kuma ta kammala da nau'ikan a cikin sabonin alamari (array1kuma) tare da kuma waɗannan sabonin alamari (array2 tana array3 kuma) na anshi da kuma kwayewa.
kaɗa, da array_uintersect() The difference is that key names also need to be compared. Both key values and key names (indices) are compared using callback functions.
Syntax
array_uintersect_uassoc(array1,array2,array3...myfunction_key,myfunction_value)
Parameters | Description |
---|---|
array1 | Required. The first array to be compared with other arrays. |
array2 | Required. The array to be compared with the first array. |
array3,... | Optional. Other arrays to be compared with the first array. |
myfunction_key |
Required. The name of the user-defined function used to compare array key names. Define callable comparison functions. If the first parameter is less than or equal to or greater than the second parameter, the comparison function must return an integer less than or equal to or greater than 0. |
myfunction_value |
Required. The name of the user-defined function used to compare array key values. Define callable comparison functions. If the first parameter is less than or equal to or greater than the second parameter, the comparison function must return an integer less than or equal to or greater than 0. |
Use user-defined callback functions myfunction_key And myfunction_value To calculate the intersection of two or more arrays (i.e., array1 That exist in both the array and in any other array, and return the resulting array.
Compare both key names and key values, such as "a"=>1 and "b"=>1, these two elements are not equal.
myfunction_key The specified function is used to compare whether the key names are equal.myfunction_value The specified function is used to compare whether the key values are equal. Both functions have two parameters to be compared.
The array returned keeps the key names unchanged.
Technical Details
Return value: | Returns an array containing all the elements that exist array1 In all other arrays at the same time. |
PHP Version: | 5+ |