- //高亮显示函数
- function bat_highlight($message,$words,$color = '#ff0000'){
- if(!empty($words)){
- $highlightarray = explode('+',$words);
- $sppos = strrpos($message,chr(0).chr(0).chr(0));
- if($sppos!==FALSE){
- $specialextra = substr($message,$sppos+3);
- $message = substr($message,0,$sppos);
- }
- $message = preg_replace(array("/(^|>)([^<]+)(?=<|$)/sUe","/<highlight>(.*)<\/highlight>/siU"),array("\highlight('\\2', \$highlightarray, '\\1')","<strong><font color=\"$color\">\\1</font></strong>"),$message);
- if($sppos!==FALSE){
- $message = $message.chr(0).chr(0).chr(0).$specialextra;
- }
- }
- return $message;
- }
- function highlight($text, $words, $prepend) {
- $text = str_replace('\"', '"', $text);
- foreach($words AS $key => $replaceword) {
- $text = str_replace($replaceword, '<highlight>'.$replaceword.'</highlight>', $text);
- }
- return "$prepend$text";
- }
|