note 76616 added to function.str-replace
| From: | Dogus at osu1 dot php dot net | Date: | Mon, 23 Jul 2007 10:44:10 +0000 |
| Subject: | note 76616 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128835@lists.php.net to get a copy of this message | ||
Another case insensitive string highlight function;
function highlightText($txt,$orgStr){
$upperTxt = strtoupper($txt);
$lowerTxt = strtolower($txt);
$newStr = str_replace($upperTxt,'<span
class="highlighted">'.$upperTxt.'</span>',$orgStr);
return str_replace($lowerTxt,'<span
class="highlighted">'.$lowerTxt.'</span>',$newStr);
}
And add this definition to your css file;
.highlighted{background-color:yellow;/*or something else*/}
That's all, have fun ;)
----
Server IP: 69.147.83.197
Probable Submitter: 164.128.46.170 (proxied: 43.204.34.12)
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/76616
Del: integrated -- https://master.php.net/note/delete/76616/integrated
Del: useless -- https://master.php.net/note/delete/76616/useless
Del: bad code -- https://master.php.net/note/delete/76616/bad+code
Del: spam -- https://master.php.net/note/delete/76616/spam
Del: non-english -- https://master.php.net/note/delete/76616/non-english
Del: in docs -- https://master.php.net/note/delete/76616/in+docs
Del: other reasons-- https://master.php.net/note/delete/76616
Reject -- https://master.php.net/note/reject/76616
Search -- https://master.php.net/manage/user-notes.php