You can replace it with anything:
$sentence = str_replace('word', '', $sentence);
Although it will also destroy words like swordfish , turning them into sfish . This way you can put spaces around the edges:
$sentence = str_replace(' word ', ' ', $sentence);
But then it will not correspond to the words at the end and beginning of sentences. Therefore, you may need a regular expression:
$sentence = preg_replace('/\bword\b/', '', $sentence);
\b is the word boundary, which can be a space or the beginning of a line, or something like that.
source share