Answer the question
In order to leave comments, you need to log in
How to remove words contained in another array in an array from strings?
There is an array, for example: array1 = ( 'красная шапочка', 'серый волк' )
and another one: array2 = ( 'красная', 'серый' )
What is the best way to get an array res= ( 'шапочка', 'волк' )
?
Answer the question
In order to leave comments, you need to log in
Well, for example:
$array1 = ['красная шапочка', 'серый волк'];
$array2 = ['красная', 'серый'];
function rep($val)
{
global $array2;
return str_replace($array2, '', $val);
}
$array3 = array_map('rep', $array1);
print_r($array3);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question