2. Add a style to your stylesheet: .highlight {background:yellow} */ if (!defined('PmWiki')) exit(); function highlight_capture_start() { if ( $action && $action != 'browse' ) { return ;} ob_start(); } function highlight_capture_stop() { if ( $action && $action != 'browse' ) { return ;} # q,sa_q google;p yahoo;text pmwiki $ref_patterns=array("/^search_for=(.*)/","/^query=(.*)/","/^q=(.*)/","/^as_q=(.*)/","/^p=(.*)/","/^text=(.*)/"); $text = ob_get_clean(); $refer=preg_replace("/^.*\?(.*)/","$1",$_SERVER["HTTP_REFERER"]); #$refer="q=Kaasfondue+a+site:http://www.brambring.nl#1&num=20&hl=en&lr=lang_nl|lang_en&ie=UTF-8&oe=UTF-8&start=20&sa=N"; foreach ( explode ("&",$refer) as $qsa ) { $words=preg_replace($ref_patterns,"$1",$qsa); if ( $words != $qsa ) { $words=preg_replace("/[\+\-\"\']/"," ",urldecode($words)); foreach ( explode (" ",$words) as $word ) { if ( $word ) { # in case there where double spaces highlight($text,$word) ; } } } } echo $text; } function highlight(&$text,$word) { $word=preg_replace("/#/","\#",$word); $pregmatch="#(\b)($word)(\b)(?![^<]*>)#i"; $pregreplace="$1$2$3"; $text=preg_replace($pregmatch,$pregreplace,$text); } ?>