how to check if two arrays matches with each other
Posted: Tue Dec 29, 2009 8:57 pm
Hi,
How to check if two arrays matches with each other?
This is not working obviously.
But this works if $pattern is just a value or string, like this,
But I have a couple of keywords in $pattern I want to check if any of them matches the keywords in $array...
Many thanks if you have any idea.
Thanks,
Lau
How to check if two arrays matches with each other?
Code: Select all
$array = array("arts","photograph","drawing");
$patern = array("photograph","drawing");
if (in_array($patern, $array)) {
echo 'found';
}But this works if $pattern is just a value or string, like this,
Code: Select all
$array = array("arts","photograph","drawing");
$patern = "photograph";
if (in_array($patern, $array)) {
echo 'found';
}Many thanks if you have any idea.
Thanks,
Lau