note 27741 added to function.str-replace

From: Date: Tue, 17 Dec 2002 13:54:22 +0000
Subject: note 27741 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-41014@lists.php.net to get a copy of this message
To do a 'Google' alike highligh with keeping the original case (improved version): // highlights words in text (default like Google, set $hs and $he to change) function highlight( $words, $haystack, $hs = '<b style="color: black; background-color: #ffff66">', $he = '</b>'){ if (is_array( $words)) foreach( $words as $word) $haystack = preg_replace('|\b('.quotemeta($word).')\b|iU', $hs.'\\1'.$he, $haystack); else $haystack = preg_replace('|\b('.quotemeta($words).')\b|iU', $hs.'\\1'.$he, $haystack); return $haystack; } -- http://www.php.net/manual/en/function.str-replace.php http://master.php.net/manage/user-notes.php?action=edit+27741 http://master.php.net/manage/user-notes.php?action=delete+27741 http://master.php.net/manage/user-notes.php?action=reject+27741

« previous php.notes (#41014) next »