PHP从数组中删除常用单词

How would you remove common words (the, is, a, as) from the the English language in PHP from an array?

Example of an array could be

$story = array("Jack", "is", "going", "out", "to", "play");

If you need to preserve the content of the array and have it empty if you replace everything in every element...

$common = ["the", "as", "is", "a"];

foreach($array as &$element) {
    $element = str_replace($common, "", $element);
}

This should work. Let's say you have your content in $array, we are looping on it and remove from each element the content of $common which you can customize as you need.

Otherwise, if you have to "pop" the element ("pop" for "remove completely")...

foreach ($array as $k => $v) {
   if (in_array($v, $common)){
      unset($array[$k])
   }
}

You can unset the array

    $unwanted_array = array("a","the","un");

    foreach ($your_array as $key=>$value) {
       if (in_array($value,$unwanted_array)){
          unset($your_array[$key])
       }
    }

Or you can also try using array_diff

    $your_array = array_diff($your_array  $unwanted_array );