Php Remove Stop Words From String

[Solved] Php Remove Stop Words From String | Php - Code Explorer | yomemimo.com
Question : php remove stop words from string

Answered by : geeky-bravo

 public function optimizeSearchString($searchString = "") { $stopwords = array( 'der' => 1, 'die' => 1, 'das' => 1, 'the' => 1); $words = preg_split('/[^-\w\']+/', $searchString, -1, PREG_SPLIT_NO_EMPTY); if (count($words) > 1) { $words = array_filter($words, function ($v) use (&$stopwords) { return !isset($stopwords[strtolower($v)]); } ); } if (empty($words)) { return $searchString; } return implode(" ", $words); }

Source : https://stackoverflow.com/questions/32310787/remove-stop-words-from-searchstring-in-php | Last Update : Wed, 09 Sep 20

Answers related to php remove stop words from string

Code Explorer Popular Question For Php