note 83093 deleted from function.str-replace by danbrown

From: Date: Sun, 20 Jul 2008 16:14:43 +0000
Subject: note 83093 deleted from function.str-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142167@lists.php.net to get a copy of this message
Note Submitter: eye-c dot ca at hotmail dot com ---- 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; } }

« previous php.notes (#142167) next »