How to check if multiple element are in an array using PHP

We generally use in_array function to check if an element is in array or not , but this function does not allow as to check multiple elements in the array. so in today’s post i just wanted to share small code snippets for checking multiple values in an array.

Here array_intersect() function compare the values of two arrays, and return the matches, and that matches count should be equal to the $search array items count. if both are equal it will return true otherwise it will return false.

you can use the above function as shown below , it will return Boolean value.

That’s it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets. Protection Status