PHP array_uintersect_uassoc() Funksie
Voorbeeld
Vergelyk die sleutels en waardes van twee skikkings (gebruik twee gebruikergedefinieerde funksies vir vergelyking) en gee die passings terug:
<?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);
?>
Definisie en gebruik
Die array_uintersect_uassoc() funksie vergelyk die sleutels en waardes van twee of meer skikkings, en gee die passings terug.
Let wel: Hierdie funksie gebruik twee gebruikergedefinieerde funksies vir vergelyking; die sleutel word in die eerste funksie gebruik en die waarde word in die tweede!
Hierdie funksie vergelyk die sleutels en waardes van twee (of meer) skikkings, en gee 'n skikking terug wat die inskrywings van skikking1 bevat wat teenwoordig is in skikking2, skikking3, ens.
Sintaksis
array_uintersect_uassoc(array1, array2, array3, ..., myfunc_key, myfunc_value)
Parameterwaardes
Parameter | Description |
---|---|
array1 | Required. The array to compare from |
array2 | Required. An array to compare against |
array3,... | Optional. More arrays to compare against |
myfunc_key | Required. The name of the user-defined function that compares
the array keys. A string that define a callable comparison function. The comparison function must return an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument |
myfunc_value | Required. The name of the user-defined function that compares
the array values. A string that define a callable comparison function. The comparison function must return an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument. |
Tegniese besonderhede
Terugkeerwaarde: | Wys 'n skikking wat die inskrywings van skikking1 bevat wat in al die ander skikkings teenwoordig is |
---|---|
PHP weergawe: | 5+ |
❮ PHP Skikking Verwysing