note 44877 added to function.str-ireplace
| From: | theblasp at gmail dot com | Date: | Wed, 18 Aug 2004 18:35:59 +0000 |
| Subject: | note 44877 added to function.str-ireplace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74895@lists.php.net to get a copy of this message | ||
Because I needed this function on a PHP4 box, I wrote it myself using strpos.
Feel free to use it, or suggest improvements :)
<?php
function my_str_ireplace($from,$to,$msg) {
$offset=0;
$res="";
$lmsg=strtolower($msg);
while ($found=strpos($lmsg,$from,$offset)) {
$res.=substr($msg,$offset,$found-$offset);
$res.=$to;
$offset=$found + strlen($from);
}
$res.=substr($msg,$offset);
return $res;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.str-ireplace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44877
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44877&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44877&report=yes
Search -- http://master.php.net/manage/user-notes.php