PHP: Check if an array contains all array values from another array
You can use the array_diff function in PHP to compare two arrays and check if the first array contains all of the values from the second array.
You can use the array_diff function in PHP to compare two arrays and check if the first array contains all of the values from the second array.
Example of using the array_diff function in PHP to compare two arrays
php— editable, runs on the server
<div class="alert alert-info flex not-prose">![]()
<span class="hidden md:block">Watch a video course</span>Learn object oriented PHP</div>
You can also use array_intersect to check if all elements of second array are present in first array.
Example of using the array_intersect function in PHP to compare two arrays
php— editable, runs on the server