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
 [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

Pull Requests

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 Dec 21 12:01:31 2024 UTC