Je cherche a mettre en gras des mots dans un texte comme le fait google, grâce a la fonction eregi mais je n y arrive pas.
Voici mon code:
Code : Tout sélectionner
function hilight_text($text,$word_to_hilight)
{
eregi('(([a-z0-9]+ ){0,2})((('.$word_to_hilight.')(e|es)?)( (('.$word_to_hilight.')(e|es)?))*)(( [a-z0-9]+){0,2})',$text,$items);
echo '<pre>';
print_r($items);
echo '</pre>';
return '<i>'.$items[1].'<b>'.$items[3].'</b>'.$items[11].'</i><br />';
}
echo hilight_text('test du decoupage du mot bateau, le mot bateau devrai se mettre en gras','bateau');Pourriez-vous m'aider s'il vous plait.
Merci