두 개의 비 연관 배열을 비교하여 일치하는 배열을 새로 만들려고합니다.PHP- 두 배열이 일치하는 배열 만들기
//This array has several entries
$a_firstarray = Array();
//This array has less entries than the first array
$a_secondarray = Array();
//This array should contain the matches of the first array and the second array in no particular order
$a_mergedarray
for($i=0;$i <=count($a_firstarray);$i++){
for($a=0;$a <=count ($a_secondarray);$a++){
if($a_firstarray[$i] == $a_secondarray[$a]){
$a_mergedarray[] = $a_activecategory[$i];
}
}
}
그것은 어떤 이유로 작동하지 않습니다
이 내가 생각해야하는 것이다. 나는 또한 PHP가 이것을하는 어떤 종류의 함수를 가지고 있다고 확신한다. 어떤 아이디어? 미리 감사드립니다.
왜 [**'array_intersect()'**] (http://www.w3schools.com/php/func_array_intersect.asp)를 사용하지 않으시겠습니까? – Phiter