note 83093 added to function.str-replace
| From: | eye-c dot ca at hotmail dot com | Date: | Fri, 09 May 2008 16:27:04 +0000 |
| Subject: | note 83093 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139219@lists.php.net to get a copy of this message | ||
followup to marc at palaueb dot com str_rreplace
The function replaced the first character of the string if no character was found so I transformed
it to check if the caracter exists in the string and to return an unchaged string if it is not
there.
function str_rreplace($search,$replace,$subject){
if (strpos($subject,$search) !== false){
$strrpos=strrpos($subject,$search);
return substr_replace($subject,$replace,$strrpos,strlen($search));
}
else{
return $subject;
}
}
----
Server IP: 64.71.164.2
Probable Submitter: 207.134.67.187
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/83093
Del: integrated -- https://master.php.net/note/delete/83093/integrated
Del: useless -- https://master.php.net/note/delete/83093/useless
Del: bad code -- https://master.php.net/note/delete/83093/bad+code
Del: spam -- https://master.php.net/note/delete/83093/spam
Del: non-english -- https://master.php.net/note/delete/83093/non-english
Del: in docs -- https://master.php.net/note/delete/83093/in+docs
Del: other reasons-- https://master.php.net/note/delete/83093
Reject -- https://master.php.net/note/reject/83093
Search -- https://master.php.net/manage/user-notes.php