note 36612 deleted from function.str-replace by bjori

From: Date: Sun, 26 Mar 2006 22:22:34 +0000
Subject: note 36612 deleted from function.str-replace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106669@lists.php.net to get a copy of this message
Note Submitter: t at seebach dot dk ---- A simple way of making a case insensitive, multiple words (array) highligt of a string: <?php $needle = array("foo","bar","boo"); // use the | to make preg_replace to use multiple values $needle = join('|',$needle); // use the /i to make case insensitive and \\0 not replace th word but simply to wrap the word. $text = preg_replace("/($needle)/i","<b>\\0</b>",$haystack); ?> Hope you can use it, enjoy Torben

« previous php.notes (#106669) next »