note 27741 deleted from function.str-replace by aidan

From: Date: Sat, 26 Jun 2004 14:48:26 +0000
Subject: note 27741 deleted from function.str-replace by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71782@lists.php.net to get a copy of this message
Note Submitter: jeroen-at-zwolnet-dot-com ---- To do a 'Google' alike highligh with keeping the original case (improved version): <?php // 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; } ?>

« previous php.notes (#71782) next »