Check whether the array contain all element of other array?
php
Solution
Use `array_intersect()` and test that its output is the same length:
if (count(array_intersect($arr1, $arr2)) === count($arr1)) {
// contains all
}
For an associative array where keys must also match, use `array_intersect_assoc()` instead.
Problem
I have 2 array , the second array must contain all the element in first array , how to check this ? Thank you ``` For example array 1: Array ( [0] => Email [1] => 1_Name ) array 2: Array ( [0] => 1_Name [1] => ) In this case it is invalid , as array 2 do not have Email array 1: Array ( [0] => Email [1] => 1_Name ) array 2: Array ( [0] => 1_Name [1] => Address [2]=> Email ) In this case it is valid ```