I have an array of strings
$array = array("are", "finite", "get", "er");
and a string
$string = "You are definitely getting better today";
I expect this output
You today
I want to remove all the array values from the string efficiently, if array value is part of a word in the string whole word must also be removed from string.
Here is my code on which I am working at the moment
foreach ($array as $a)
{
$string = str_replace($a, "", $string);
}
echo $string;
It removes array values from the string, but it do not remove words that contain array values.
Edit:
As my strings are user provided and are about 4096 characters long, someone please guide me which answer is more efficient with respect of speed and memory usage.
