|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39059 str_replace: fourth parameter is always zero
Submitted: 2006-10-06 10:46 UTC Modified: 2006-10-07 09:38 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dirk dot thomas at 4wdmedia dot de Assigned:
Status: Closed Package: Strings related
PHP Version: 5CVS-2006-10-06 (snap) OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dirk dot thomas at 4wdmedia dot de
New email:
PHP Version: OS:


 [2006-10-06 10:46 UTC] dirk dot thomas at 4wdmedia dot de

first: i am using the latest Win32-binary currently available from (php5.2-win32-200610051830) with an Apache 2.2 (sapi).

When calling the function str_replace the fourth parameter - which should be set to the number of replacements - is always set to zero.

With Php5.1.1 and an Apache 2.0.55 it works as expected.

Best regards,

Reproduce code:
$c = 23;
echo str_replace('i', 'o', 'string', $c);
echo ' '.$c;

Expected result:
strong 1

Actual result:
strong 0

Even one string replacement took place ('i' => 'o'), the referenced value for counting is set to zero.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-06 11:04 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-10-06 12:32 UTC] third-chance at gmx dot de
I have tried it with the version from your link.
The problem persists and is still the same.
 [2006-10-06 12:44 UTC]
Please make sure you deleted php5ts.dll from 5.1.6 and put the one from the snapshot instead.
I cannot reproduce it with the snapshot.
 [2006-10-06 14:22 UTC] third-chance at gmx dot de
I do not have any old version of php5ts.dll anywhere. Just the current on in the php-directory.
 [2006-10-06 15:20 UTC]
Just tried php-5.2.0RC5 and it works as expected.
 [2006-10-06 16:08 UTC] third-chance at gmx dot de
I tried again using the cli in a fresh directory. The problem is still their.
I also tried with an older snapshot from my disc (php5.2-win32-200608171030): just the same.

When using for example the release 5.1.6 everything works fine.

Are their anywhere older snapshots to norrow down the timewindow? Perhaps i could find the point between to snaps, where it stops working on my computer?

PS: i encouter the same problem with the latest 6.0-snap
 [2006-10-06 17:26 UTC] third-chance at gmx dot de
A friend of mine testet the latest snap on his computer and encoutered the same bug.
He also uses WinXP SP2 and called the cli of php for the test.
 [2006-10-07 09:15 UTC] dirk dot thomas at 4wdmedia dot de
I have testet the example-script with the updated snapshot. Now it works as expected!

So it looks like that this bug has been fixed between the two snaps:

I could not test the php6-version, because their are no current win32-builds available (last is 20060924).

Thank you
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 27 09:01:25 2020 UTC