I am trying to do something like this:
$fetch = array('a', 'b', 'c', 'd', 'e');
$input = array('a', 'c', 'e');
if (in_array($input, $fetch)) {
echo "Array Values Exists";
}
else {
echo 'Invalid Values Exists';
}
Basically, I am trying to see if the values in $input array exists in the $fetch array. But the above results always shows as Invalid Values Exists instead of showing Array Values Exists. When I read the in_array() documentation here, from example #3, I thought I can use array in array for the parameters. Have I understood this wrong? What is the right way to do this?
array_intersect()will work perfect for me since I am actually using this to match and validate the checkbox values from$_POSTandarray_intersect()will actually work well to filter out the array values instead of using a foreach statement that will be a few more lines of codes. Thank you for that.