php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52362 give str_ireplace an option to refer the original string
Submitted: 2010-07-16 14:13 UTC Modified: 2010-07-19 11:45 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: emiobe at guehring dot de Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.3.2 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-07-16 14:13 UTC] emiobe at guehring dot de
Description:
------------
Currently I can search case-insensitive with str_ireplace. But when I need the original string in the replacement I have to use preg_replace//i. 

It would be nice to have the original text in a "magic variable" like $1 to avoid using the "expensive" preg-engine.

Test script:
---------------
currently:

print str_ireplace ("original", "<b>original</b>", "the ORIGINAL text");

idea:

print str_ireplace ("original", "<b>$1</b>", "the ORIGINAL text");


Expected result:
----------------
the <b>original</b> text

Actual result:
--------------
the <b>ORIGINAL</b> text

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-16 14:21 UTC] giorgio dot liscio at email dot it
use preg_replace with /i PCRE_CASELESS identifier

bogus
 [2010-07-16 14:31 UTC] emiobe at guehring dot de
erm, just replace expected and actual result... I have mixed it up, sorry
 [2010-07-19 11:45 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2010-07-19 11:45 UTC] aharvey@php.net
The point of having the separate str_replace and str_ireplace functions
is that they're intended to be fast replacers for times when you don't
need any special features such as regular expression matching or back
references. This would introduce special case code that would only slow
them down and duplicate functionality the preg functions provide.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 02:01:30 2024 UTC