You can use array_intersect()
.
$peopleContainsCriminal = !empty(array_intersect($people, $criminals));
More Related Contents:
- Filter array by its keys using an array of allowed keys
- Remove all elements from array that do not start with a certain string
- Get difference between associative rows of two 2-dimensional arrays
- Recursively remove empty elements and subarrays from a multi-dimensional array
- How to filter an associative array comparing keys with values in an indexed array?
- Explode string into array with no empty elements?
- Native function to filter array by prefix
- Return only duplicated entries from an array (case-insensitive)
- Most efficient way to search for object in an array by a specific property’s value
- array_diff to compare two associative arrays
- count how many duplicate keys are in array of objects?
- How to add elements to an empty array in PHP?
- Compare 2-dimensional data sets based on a specified second level value
- PHP Sort Array By SubArray Value
- Using a string path to set nested array data [duplicate]
- How to get random value out of an array?
- Flatten multidimensional array concatenating keys [duplicate]
- How to get the last n items in a PHP array as another array?
- how to sort a multidemensional array by an inner key
- How to create multi-dimensional array from a list?
- how to change the array key to start from 1 instead of 0 [duplicate]
- Alternate to array_column()
- How to remove values from two arrays that have the same key and value?
- Create PHP array from MySQL column
- Recreate original PHP array from print_r output [duplicate]
- How to convert an integer to an array in PHP?
- Filter rows of a 2d array by the rows in another 2d array
- Save array in mysql database
- How to count the consecutive duplicate values in an array?
- How do I check if array contains at least one empty value?