I have two arrays and I want to compare the first with the second array. I have an IF statement and it currently does two checks:
- It checks to see if there are any rows from my query
- If the above passes, then I want to traverse the array values of the first array and compare it with the second array. I want to traverse through all the
names
first array (index 0-9) and compare it with the firstname
of the second array (index 0). Keep doing the same thing until we've compared all the indices 0-9 on the first array with all indices 0-9 of the second array. - Finally, if there is a match I want to exit my PHP script, else if there is no match I continue to do to stuff.
I have tried using the in_array()
function and that works, but only with a single variable. Something like this in_array($firstArray[0], $secondArray)
works. Something like this:
if(mysqli_num_rows($result) > 0 && in_array($firstArray[0], $secondArray)){
exit("exiting now!");
}
else {
echo "continue to do stuff...";
}
However, when I put the whole array in the inArray, it won't work. Like this:
in_array($firstArray, $secondArray)
How can I achieve this?