If you want to keep the original capitalization when replacing some text, you can use this code I wrote:
<?php
function ext_str_ireplace($findme, $replacewith, $subject)
{
// Replaces $findme in $subject with $replacewith
// Ignores the case and do keep the original capitalization by using $1 in $replacewith
// Required: PHP 5
return substr($subject, 0, stripos($subject, $findme)).
str_replace('$1', substr($subject, stripos($subject, $findme), strlen($findme)), $replacewith).
substr($subject, stripos($subject, $findme)+strlen($findme));
}
?>
Example for using:
<?php
// Will print "RePlaCeMe" with red color, but after this it would be "replaceme", not "RePlaCeMe"
echo str_ireplace('replaceme', '<font color="#FF0000">$1</font>', 'Please RePlaCeMe, OK?');
// Will print "RePlaCeMe" with red color
echo ext_str_ireplace('replaceme', '<font color="#FF0000">$1</font>', 'Please RePlaCeMe, OK?');
?>
----
Server IP: 69.147.83.197
Probable Submitter: 87.165.223.34
----
Manual Page -- http://www.php.net/manual/en/function.str-ireplace.php
Edit -- https://master.php.net/note/edit/86069
Del: integrated -- https://master.php.net/note/delete/86069/integrated
Del: useless -- https://master.php.net/note/delete/86069/useless
Del: bad code -- https://master.php.net/note/delete/86069/bad+code
Del: spam -- https://master.php.net/note/delete/86069/spam
Del: non-english -- https://master.php.net/note/delete/86069/non-english
Del: in docs -- https://master.php.net/note/delete/86069/in+docs
Del: other reasons-- https://master.php.net/note/delete/86069
Reject -- https://master.php.net/note/reject/86069
Search -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.