Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Lori DK
Added: Jul 17, 2018 6:38 PM
Views: 17
Tags: php
  1.     function trim_search($search)
  2.     {
  3.         $wordlist = array("of", "the", "town", "City", "Town", "The", "city", "Municipality", "municipality");
  4.  
  5.         foreach ($wordlist as &$word) {
  6.             $word = '/\b' . preg_quote($word, '/') . '\b/';
  7.         }
  8.  
  9.         $search_city = preg_replace($wordlist, '', $search);
  10.  
  11.         return $search;
  12.     }