note 43582 modified in function.str-replace by aidan

From: Date: Sun, 22 Aug 2004 14:01:03 +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-75109@lists.php.net to get a copy of this message
Here is a simple function for highlighting a needle in text. It is careful to not replace text in HTML tags (unless specified). http://aidan.dotgeek.org/lib/?file=function.str_highlight.php Example: The google method of highlighting <?php $text = "Here is some text with a search term"; $needle = "search term"; echo str_highlight($text, $needle); ?> Output: Here is some text with a <strong>search term</strong> --was-- Here is a simple function for highlighting a needle in text. http://aidan.dotgeek.org/lib/?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); // Output: Here is some text with a <strong>search term</strong> ?> http://php.net/manual/en/function.str-replace.php

« previous php.notes (#75109) next »