note 78011 added to function.str-replace
| From: | marc at palaueb dot com | Date: | Mon, 24 Sep 2007 08:44:25 +0000 |
| Subject: | note 78011 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130739@lists.php.net to get a copy of this message | ||
I'm searching for a function who replace the last occurrence of a string but I have not found
anything.
Check this out:
function str_rreplace($search,$replace,$subject){
$strrpos=strrpos($subject,$search);
return substr_replace($subject,$replace,$strrpos,strlen($search));
}
the only one problem is that do not have a limit to replace, just replace the last occurrence.
----
Server IP: 69.147.83.197
Probable Submitter: 217.126.43.62
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/78011
Del: integrated -- https://master.php.net/note/delete/78011/integrated
Del: useless -- https://master.php.net/note/delete/78011/useless
Del: bad code -- https://master.php.net/note/delete/78011/bad+code
Del: spam -- https://master.php.net/note/delete/78011/spam
Del: non-english -- https://master.php.net/note/delete/78011/non-english
Del: in docs -- https://master.php.net/note/delete/78011/in+docs
Del: other reasons-- https://master.php.net/note/delete/78011
Reject -- https://master.php.net/note/reject/78011
Search -- https://master.php.net/manage/user-notes.php