note 70689 added to function.str-replace

From: Date: Tue, 24 Oct 2006 02:03:47 +0000
Subject: note 70689 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-119052@lists.php.net to get a copy of this message
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 ---- Server IP: 202.89.36.242 Probable Submitter: 203.171.40.14 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/70689 Del: integrated -- https://master.php.net/note/delete/70689/integrated Del: useless -- https://master.php.net/note/delete/70689/useless Del: bad code -- https://master.php.net/note/delete/70689/bad+code Del: spam -- https://master.php.net/note/delete/70689/spam Del: non-english -- https://master.php.net/note/delete/70689/non-english Del: in docs -- https://master.php.net/note/delete/70689/in+docs Del: other reasons-- https://master.php.net/note/delete/70689 Reject -- https://master.php.net/note/reject/70689 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119052) next »