Answer the question
In order to leave comments, you need to log in
How to search for words in multiple arrays at once?
I have an array with text for example:
And two arrays with words$text = "зеленый красный желтый"
$color_a = array("зеленый","желтый");
$color_b = array("красный","черный");
$text = @explode(" ",$text);
foreach($text as $word){
foreach ($color_a as $aword) {
if($word == $aword)
{
echo 'a++';
}
}
foreach ($color_b as $bword) {
if($word == $bword)
{
echo 'b++';
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question