|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
40 - 5 = ?
Subscribe to this entry?

 [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: Tue Jul 23 13:01:30 2024 UTC