note 43582 modified in function.str-replace by aidan

From: Date: Thu, 16 Nov 2006 02:27:58 +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-119782@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://aidanlister.com/repos/v/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. 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> http://php.net/manual/en/function.str-replace.php

« previous php.notes (#119782) next »