Quick Search:
 
 PHP Code: Perfect Highlighting Function Jump to:  
Category: >> PHP Code >> Perfect Highlighting Function  

<< lastnext >>

Snippet Name: Perfect Highlighting Function

Description: This one works very well. :)

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: February 27th, 2009

<?PHP
 
// highlight words in a string 
FUNCTION highlight($text, $search) {
   $text = PREG_REPLACE( "/(^|\s|,!|;)(".PREG_QUOTE($search, "/").")(\s|,|!|&|$)/i", "\\1<span class='hlstyle'>\\2</span>\\3", $text );
   RETURN $text;
}
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org