dunque ho provato ma c'č qualcosa che non va
la funzione completa č questa, perchč magari facciamo confusione e non arriviamo mai alla conclusione e io poi, abuso della tua cortesia
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ricerca ed evidenzia case insensitive senza PHP 5</title>
<style type="text/css">
body {font-family: Tahoma, Verdana, sans-serif;}
.motore{font-weight:bold;color:#ff0000;}
#red {width:20px;height:20px;background:red;}
#blue {width:20px;height:20px;background:blue;}
</style>
</head>
<body>
<?
function grassettoMultiplo($stringa, $parole) {
for($a = 0, $b = count($parole); $a < $b; $a++)
$stringa = grassetto($stringa, $parole[$a]);
return $stringa;
}
function grassetto($stringa, $parola){
//return preg_replace("/(?i)([^<]\b)({$parola})(\b[^>])/", "\\1<span class='motore'>\\2</span>\\3", $stringa);
$stringa2 = preg_replace("/(?i)([^<]*?)({$parola})([^>]*?)/", "\\1<span class='motore'>\\2</span>\\3", $stringa);
$rex = '/(<((img|input|link|meta)|[a-z]+).*?)<span.*?>(.*?)<\/span>(.*?(?(3)>|<\/\\2>))/is' ;
$stringa = preg_replace($rex,'$1$4$5',$stringa2) ;
return $stringa;
}
$testo = "Hello <span id='test'>my</span> World pippo questo
il logo
<acronym title='prova testo pippo'>prova</acronym>";
?>
<form id="prova" action="testa.php" method="post" enctype="multipart/form-data">
<input type="text" name="cerca" value="" />
<input type="submit" name="invia" value="Cerca" />
</form>
<div style="border:1px solid silver;margin-top:10px;padding:5px;">
<?
if($_REQUEST['cerca']!=''){
$cerca = explode (' ', $_REQUEST['cerca']);
echo grassettoMultiplo($testo, $cerca);
}else{
echo $testo;
}
?>
</p></div>
</body>
</html>
cosė basta un copia e incolla, e vediamo quanto sono idiota