ID: 11457 Updated by: [EMAIL PROTECTED] Reported By: adamw at uscho dot com -Status: Open +Status: Assigned Bug Type: Feature/Change Request PHP Version: 4.0.5 -Assigned To: +Assigned To: pollita New Comment:
As of 5.0.0 the last parameter (count) is passed by reference (it is optional). So 2 choices : 1)passed not by reference - it's limit 2)passed by reference : the var is is_null() - all occurences are replaced the number is returned in "count", otoh if the var !is_null() -> use as limit. Comments? Previous Comments: ------------------------------------------------------------------------ [2001-06-13 01:51:51] adamw at uscho dot com I've been racking my brain attempting to figure out a way to replace only the first instance of a specified string within a larger string. Obviously - str_replace does this ... but it does it for *all* instances. Other functions will *find* the first instance, but won't act upon it. I noticed, however, that "preg_replace" has a fourth parameter ... the "limit" parameter. How nice would this be for "str_replace" to have that 4th parameter?! It would avoid the need to use a regular expression function. I am open to workarounds and alternatives. Thank you for the consideration. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=11457&edit=1