Text
|
|
|
|
<?php
function replacestring($search,$replace,$subject) {
$srchlen=strlen($search); // lenght of searched string
if ($srchlen==0) return $subject;
$find = $subject;
while ($find = stristr($find,$search)) { // find $search text in $subject - case insensitiv
$srchtxt = substr($find,0,$srchlen); // get new search text
$find=substr($find,$srchlen);
$subject = str_replace($srchtxt,$replace,$subject); // replace founded case insensitive search text with $replace
}
return $subject;
}
$a="Hello world, hello world, hello World, HelLo WOrld";
echo replacestring("hello","<b>hello</b>",$a);
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|