php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64259 Create strn_replace() function
Submitted: 2013-02-21 00:07 UTC Modified: 2021-03-17 17:05 UTC
From: d at duane dot com Assigned:
Status: Suspended Package: Strings related
PHP Version: 5.4.11 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: d at duane dot com
New email:
PHP Version: OS:

 

 [2013-02-21 00:07 UTC] d at duane dot com
Description:
------------
It'd be great to have a version of str_replace()  that can be configured to work 
on a specified number of replacements.

I propose that the function 

mixed strn_replace ( mixed $search , mixed $replace , mixed $subject, int 
$repetitions, [, int &$count ] )

Be created, which would do the same thing as str_replace() but only as many 
times as $repetitions was set to.

See further discussion of the ways this problem is currently solved.

http://stackoverflow.com/questions/1252693/php-str-replace-that-only-acts-on-
the-first-match

I am up for adding this code in as a patch, but it'd be nice to have some 
feedback if this is desired.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-17 17:05 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-03-17 17:05 UTC] cmb@php.net
If you, or anybody else for that matter, is still interested in
this feature, please pursue the RFC process[1].  For the time
being, I suspend this ticket.

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 09:03:37 2021 UTC