Use array_diff()
:
$arr1 = array(1,2,3);
$arr2 = array(1,2,3,4,5,6,7);
$arr3 = array_diff($arr1, $arr2);
if (count($arr3) == 0) {
// all of $arr1 is in $arr2
}
More Related Contents:
- How to search by key=>value in a multidimensional array in PHP
- Find a matching or closest value in an array
- Search for a key in an array, recursively
- Compare multidimensional arrays in PHP
- Check if a specific value exists at a specific key in any subarray of a multidimensional array
- How to check if a specific value exists at a specific key in any subarray of a multidimensional array?
- Recursive array_search
- Check if string contains word in array [duplicate]
- Can I bind an array to an IN() condition in a PDO query?
- Creating one array from another array in php [closed]
- How to echo or print an array in PHP?
- PHP Constants Containing Arrays?
- Reference – What does this error mean in PHP?
- Sorting a php array of arrays by custom order
- php glob – scan in subfolders for a file
- How do I sort a multidimensional array by one of the fields of the inner array in PHP? [duplicate]
- Notice: Array to string conversion in
- Removing array item by value [duplicate]
- Checking if array is multidimensional or not?
- array_key_exists is not working
- Parse error: Invalid numeric literal
- Notice: Undefined index when trying to increment an associative array in PHP
- PHP – Get key name of array value
- Remove unwanted elements from subarrays in multidimensional array
- How to convert array to a string using methods other than JSON?
- Sort array by value alphabetically php
- Array size limit in PHP
- Sort a multidimensional array descending by subarray count and preserve first level keys
- How are associative arrays implemented in PHP?
- Why does PHP not complain when I treat a null value as an array like this?