note 86177 added to function.str-replace

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
I tried max at efoxdesigns dot com solution for str_replace_once but it didn't work quite right so I came up with this solution (all params must be strings):

<?php
function str_replace_once($search, $replace, $subject) {
	$firstChar = strpos($subject, $search);
	if($firstChar !== false) {
		$beforeStr = substr($subject,0,$firstChar);
		$afterStr = substr($subject, $firstChar + strlen($search));
		return $beforeStr.$replace.$afterStr;
	} else {
		return $subject;
	}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 75.100.120.26
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit        -- https://master.php.net/note/edit/86177
Del: integrated  -- https://master.php.net/note/delete/86177/integrated
Del: useless     -- https://master.php.net/note/delete/86177/useless
Del: bad code    -- https://master.php.net/note/delete/86177/bad+code
Del: spam        -- https://master.php.net/note/delete/86177/spam
Del: non-english -- https://master.php.net/note/delete/86177/non-english
Del: in docs     -- https://master.php.net/note/delete/86177/in+docs
Del: other reasons-- https://master.php.net/note/delete/86177
Reject      -- https://master.php.net/note/reject/86177
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.