bonjour,
dans mon moteur de recherche, je souhaite mettre en évidence tous les mots recherchés.
j'ai un comportement bizarre avec le <span>
en effet si ma chaine de recherche contient une des lettres du code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<span style="background-color:#ffcc00">
alors je retrouverai ce paramètre dans ma recherche ???
ex : si ma chaine vaut : recherche color
je vais retouver en résultat :
recherchecolor:#ffcc00">recherchecolor:#ffcc00">recherchecolor:#ffcc00">recherchecolor:#ffcc00...

si je retire du code l'attribut donné à span alors je n'ai plus de problème.
comment faire pour que ma variable sortie accepte le <span style...>

voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
$description=mysql_result($selection_recherche,$i,"description" );
    $titre=mysql_result($selection_recherche,$i,"titre" );
	$titre = "<b><FONT color = blue>$titre</FONT></b>";
    $mots[$nombre_mots_boucle]= $recherche;
    $rech[0]= "/($mots[0])/i"; // i permet de conserver la casse
	$rech[1]= "/($mots[1])/i"; // i permet de conserver la casse
	$sortie[0]='<span style="background-color:#ffcc00"><b>$1</b></span>';
	$sortie[1]='<span style="background-color:#ffcc00"><b>$1</b></span>';
echo preg_replace($rech,$sortie,$titre);
	echo "<br>";
	echo preg_replace($rech,$sortie,$description);
    echo"<br>";