|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13319 ereg_replace() with numeric 2nd argument
Submitted: 2001-09-15 12:13 UTC Modified: 2001-09-15 13:56 UTC
From: joseph_a at mail dot ru Assigned:
Status: Closed Package: Regexps related
PHP Version: 4.0.6 OS: Linux
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: joseph_a at mail dot ru
New email:
PHP Version: OS:


 [2001-09-15 12:13 UTC] joseph_a at mail dot ru
When using ereg_replace() with a numeric 2nd argument (replacement string), this argument is treated as an empty string.
ereg_replace('4', 3, '124') produces '12' instead of '123'.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-15 13:11 UTC]
You are correct in saying that the second argument is a
'replacement string', not a number. The documentation
is very clear about this.
 [2001-09-15 13:11 UTC]
 [2001-09-15 13:26 UTC] joseph_a at mail dot ru
But preg_replace('/4/', 3, '124') will produce '123' as 
expected. Even if it's not a bug, it still would be nice 
if that number would be autoconverted to string.

 [2001-09-15 13:42 UTC]
This is impossible due to the fact that ereg_replace() supports the specifying of ascii values as a replacement argument.
 [2001-09-15 13:56 UTC] joseph_a at mail dot ru
But this also happends with double, not only with integer. 
In this case it should be possible to autoconvert it to 

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 09:01:32 2024 UTC