On Fri, Jan 9, 2015 at 1:08 AM, François Laupretre <franc...@tekwire.net> wrote:
> Hi, > > I just created the RFC : > > https://wiki.php.net/rfc/cyclic-replace > > I tried to include everything we agreed upon. Tell me if I missed > something. > > Please note that the current PR does not implement the whole RFC. You may > review the RFC while I update the code. > > Please also give me your opinion about implementing a similar feature in > preg_replace() and preg_filter(). > When submitting an RFC, please open a separate thread. Otherwise people who do not follow every single discussion will not see it. I'm against this RFC. Not because I don't like the implementation or similar, I simply don't consider this functionality to be sufficiently important to warrant both the additional internal complexity it adds and the complexity it adds to our user-facing API. str_replace is a simple function for string replacement. It has some (imho also unnecessary) extra gimmicks to implicitly do a foreach() loop during the replacement. This is still relatively simple API-wise. But if I see this (taken from the tests) as the search & replacement values... $search=array('[?]',array('(?)','d','e'),'a','R'); $repl=array( array('ap(?)z[?]',"b[?](?)v",null,37,"[?]n[?]"), array('a',array('b',null)), array('k(?)j[?]') ); ... I have a pretty hard time figuring out what this is actually supposed to do. At this point str_replace is working on arbitrarily-nested arrays and also has four options to control its behavior. Imho this is just too much complexity for a relatively minor use case. Nikita