PHP array_intersect_assoc() 함수
예시
두 배열 의 키와 값 을 비교하고 일치 항목을 반환합니다.
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("a"=>"red","b"=>"green","c"=>"blue");
$result=array_intersect_assoc($a1,$a2);
print_r($result);
?>
정의 및 사용
array_intersect_assoc() 함수는 두 개(또는 그 이상) 배열 의 키와 값 을 비교하고 일치 항목을 반환합니다.
이 함수는 두 개 이상의 배열의 키와 값을 비교하고 array2 , array3 등에 있는 array1 의 항목을 포함하는 배열을 반환합니다.
통사론
array_intersect_assoc(array1,array2,array3, ...)
매개변수 값
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 |
기술적 세부 사항
반환 값: | 다른 모든 배열에 있는 array1 의 항목을 포함하는 배열을 반환합니다. |
---|---|
PHP 버전: | 4.3.0+ |
더 많은 예
예시
세 배열 의 키와 값 을 비교하고 일치 항목을 반환합니다.
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("a"=>"red","b"=>"green","g"=>"blue");
$a3=array("a"=>"red","b"=>"green","g"=>"blue");
$result=array_intersect_assoc($a1,$a2,$a3);
print_r($result);
?>
❮ PHP 배열 참조