1 2 3 4 5 6 7 8 9 10 11
| function remplace($matches) { return '<strong>'.$matches[0].'</strong>'; }
function MotEnGras2($ancien,$origine) { return preg_replace_callback('/\b('.implode('|', $origine).')+(?:|s|e|es)\b/i','remplace', $ancien);}
$ancien = "salon de thé à Avignon théières.";
$titre="Simple Simon Avignon - Salon de thé et café, Salons de thé";
$origine = array();
$mots3 = explode(" ", trim(strtolower($titre)));
$exclure3 = array('a','un','une','de','la','du','le','les','des','et','dr','dr.','d','sur','sous','en','dans');
$replace = array("d'","m'","j'","qu'","c'","t'","l'","s'","n'","l'","-",",");
foreach($mots3 as $mot) { if (!in_array($mot,$exclure3)) { $origine[] = str_replace($replace, '', stripslashes($mot));} }
$origine = array_filter($origine);
echo MotEnGras2($ancien,$origine); |
Partager