php.net |  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:
MUST BE VALID
Solve the problem:
10 + 49 = ?
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'.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-15 13:11 UTC] swm@php.net
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] swm@php.net
closed.
 [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] sterling@php.net
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 
string.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 10:01:28 2024 UTC