note 100539 added to function.str-ireplace
| From: | stepanic dot matija at gmail dot com | Date: | Fri, 22 Oct 2010 03:57:50 +0000 |
| Subject: | note 100539 added to function.str-ireplace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173363@lists.php.net to get a copy of this message | ||
FIX-ed problem with highlighting second 'o' OR 'a', in this string
function highlight_string ($haystack, $needle, $highlight_class) {
// return $haystack if there is no highlight color or strings given, nothing to do.
$first_encode='XXXXXXXXXXXXXXX'; //ENCODE string
$second_encode='YYYYYYYYYYYYYYY';
preg_match_all("/$needle+/i", $haystack, $matches);
if (is_array($matches[0]) && count($matches[0]) >= 1) {
foreach ($matches[0] as $match) {
$haystack = str_replace($match, $first_encode.$match.$second_encode, $haystack);
}
}
$haystack=str_replace(array($first_encode,$second_encode),
array('<font class="'.$highlight_class.'"
>','</font>'),$haystack);
return $haystack;
}
----
Server IP: 193.198.184.18
Probable Submitter: 93.136.70.60
----
Manual Page -- http://www.php.net/manual/en/function.str-ireplace.php
Edit -- https://master.php.net/note/edit/100539
Del: integrated -- https://master.php.net/note/delete/100539/integrated
Del: useless -- https://master.php.net/note/delete/100539/useless
Del: bad code -- https://master.php.net/note/delete/100539/bad+code
Del: spam -- https://master.php.net/note/delete/100539/spam
Del: non-english -- https://master.php.net/note/delete/100539/non-english
Del: in docs -- https://master.php.net/note/delete/100539/in+docs
Del: other reasons-- https://master.php.net/note/delete/100539
Reject -- https://master.php.net/note/reject/100539
Search -- https://master.php.net/manage/user-notes.php