note 62604 added to function.str-replace

From: Date: Sat, 04 Mar 2006 19:04:17 +0000
Subject: note 62604 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-104831@lists.php.net to get a copy of this message
An enhancement of str_replace_once() from below (allows use of count-parameter): function str_replace_once($needle, $replace, $haystack, &$count = null) { // Looks for the first occurence of $needle in $haystack // and replaces it with $replace. $pos = strpos($haystack, $needle); if ($pos === false) { // Nothing found return $haystack; } //Populate $count str_replace($needle, $replace, $haystack, $count); //$count can never be more than 1 through this function if ($count >= 1) $count = 1; else $count = 0; return substr_replace($haystack, $replace, $pos, strlen($needle)); } ---- Server IP: 129.16.214.50 Probable Submitter: 81.225.139.6 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/note/edit/62604 Del: integrated -- http://master.php.net/note/delete/62604/integrated Del: useless -- http://master.php.net/note/delete/62604/useless Del: bad code -- http://master.php.net/note/delete/62604/bad+code Del: spam -- http://master.php.net/note/delete/62604/spam Del: non-english -- http://master.php.net/note/delete/62604/non-english Del: in docs -- http://master.php.net/note/delete/62604/in+docs Del: other reasons-- http://master.php.net/note/delete/62604 Reject -- http://master.php.net/note/reject/62604 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104831) next »