Replace Exact Occurrence of Word in PHP?

后端 未结 3 1649
耶瑟儿~
耶瑟儿~ 2021-01-14 18:46

I need to repeatedly remove certain stop words from articles. Currently I am using the function str_replace to achieve this. As the first argument I use the stop list array

3条回答
  •  萌比男神i
    2021-01-14 19:28

    This should work:

    $i = $string;
    foreach($swarray as $word) {
      $i = str_replace(" " . $word . " ", "", $i );
    }
    

提交回复
热议问题