note 43582 modified in function.str-replace by aidan

From: Date: Sun, 27 Jun 2004 13:39:59 +0000
Subject: note 43582 modified in function.str-replace by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71885@lists.php.net to get a copy of this message
Here is a simple function for highlighting a needle in text. http://ircphp.com/users/imho/?file=function.str_highlight.php For example (the google method of highlighting) <?php $text = "Here is some text with a search term"; $needle = "search term"; echo str_highlight($text, $needle); // Here is some text with a <strong>search term</strong> ?> You may also change the text to be added: <?php echo str_highlight($text, $needle, '[start]', '[end]'); // Here is some text with a [start]search term[end] ?> --was-- Simple function for highlighting a needle in text... http://ircphp.com/users/imho/?file=function.str_highlight.php For example (the google method of highlighting) <?php $text = "Here is some text with a search term"; $needle = "search term"; echo str_highlight($text, $needle); // Here is some text with a <strong>search term</strong> ?> You may also change the text to be added: <?php echo str_highlight($text, $needle, '[start]', '[end]'); // Here is some text with a [start]search term[end] ?> http://php.net/manual/en/function.str-replace.php

« previous php.notes (#71885) next »