I have two arrays:
$arr1 = array('a' => 10, 'b' => 20);
$arr2 = array('a' => 10, 'b' => 20, 'c' => 30);
How can I use array_filter() to drop elements from $arr2 that don’t exist in $arr1? Like "c" in my example.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a function specifically made for this purpose: array_intersect():
If you want to compare keys, not the values like array_intersect(), use array_intersect_key():
If you want to compare
key=>valuepairs, use array_intersect_assoc():