note 70689 deleted from function.str-replace by felipe

From: Date: Sun, 06 Jan 2008 12:47:49 +0000
Subject: note 70689 deleted from function.str-replace by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134873@lists.php.net to get a copy of this message
Note Submitter: davidwhthomas at gmail dot com ---- Just an update to Dimitri's code: Replace Once: I found this one worked best for me: function replaceOnce($search, $replace, $content){ $pos = strpos($content, $search); if ($pos === false) { return $content; } else { return substr($content, 0, $pos) . $replace . substr($content, $pos+strlen($search)); } } cheers, DT

« previous php.notes (#134873) next »