|  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: -
From: d at duane dot com Assigned:
Status: Open Package: Strings related
PHP Version: 5.4.11 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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
37 - 7 = ?
Subscribe to this entry?

 [2013-02-21 00:07 UTC] d at duane dot com
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.

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


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 05:01:23 2020 UTC