#22141 [Opn->Csd]: str_replace hangs with extra argument

From: Date: Mon, 10 Feb 2003 06:50:23 +0000
Subject: #22141 [Opn->Csd]: str_replace hangs with extra argument
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32627@lists.php.net to get a copy of this message
ID: 22141 Updated by: pollita@php.net Reported By: arlo@typea.net -Status: Open +Status: Closed Bug Type: Scripting Engine problem Operating System: Mac OS 10.2 PHP Version: 4.2.3 New Comment: This has already been fixed in CVS. PHP's internals contain two str_replace methods, the fourth parameter (when set to a non-zero value) uses the alternate search and replace method. It's not documented because the alternate method was not endoresed for use. As of 4.3.1 (which is yet to be released, you can use a snapshot from snaps.php.net in the mean time), the alternate method has been removed (and the existing method improved for speed and efficiency. Previous Comments: ------------------------------------------------------------------------ [2003-02-09 15:15:34] arlo@typea.net I was inadvertently including a fourth argument of "-1" with some instances of str_replace() -- since I got into the habit of the limit arg using preg_replace() -- and I noticed an odd behavior: str_replace("-embed-a-", "hey", "-embed-a-", -1) returns "hey," as expected. str_replace("-embed-a-", "hey", "-embed-b-", -1) returns "embed-b-," as expected. But str_replace("-embed-a-", "hey", "-embed-aa-", -1) hangs the script until the max execution time. Removing the extraneous argument made my script work properly, but I would expect PHP to either ignore the extra argument, or return an error, rather than hanging up completely. -Arlo ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22141&edit=1

« previous php.bugs (#32627) next »