1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function surl($masque){
$mask = preg_replace('\''.$masque[1].'\'', '', $masque[0], 1); //problème avec les mots doublé ex : "le le" devient "lele !"
return '<span style=\'background-color:yellow;\'>'.$mask.'<u>'.$masque[1].'</u></span>';
}
function surligne($pattyp, $pat, $txt){
switch ($pattyp){
case 'preg_match':
$out = preg_replace_callback($pat, 'surl', $txt, 1);
return $out;
break;
case 'preg_match_all':
$out = preg_replace_callback($pat, 'surl', $txt);
return $out;
break;
case 'ereg':
$out = ereg_replace($pat, '<span style=\'background-color:yellow;\'>\0</span>', $txt);
return $out;
break;
}
} |
Partager