PHP array_udiff_uassoc() 함수
예시
두 배열의 키와 값 을 비교하고 (비교를 위해 두 개의 사용자 정의 함수 사용) 차이점을 반환합니다.
<?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_udiff_uassoc($a1,$a2,"myfunction_value","myfunction_key");
print_r($result);
?>
정의 및 사용
array_udiff_uassoc() 함수는 둘 이상의 배열 의 키와 값 을 비교하고 그 차이를 반환합니다.
참고: 이 함수는 비교를 위해 두 개의 사용자 정의 함수를 사용합니다. 키는 첫 번째 기능에 사용되고 값은 두 번째 기능에 사용됩니다!
이 함수는 두 개(또는 그 이상) 배열의 키와 값을 비교하고 array2 또는 array3 등에 없는 array1 의 항목을 포함하는 배열을 반환합니다.
통사론
array_udiff_uassoc(array1, array2, array3, ..., myfunc_key, myfunc_value)
매개변수 값
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. |
기술적 세부 사항
반환 값: | 다른 배열에는 없는 array1 의 항목을 포함하는 배열을 반환합니다. |
---|---|
PHP 버전: | 5+ |
❮ PHP 배열 참조