Req #14523 [Asn->Opn]: Additional parameter for str_repeat()

From: Date: Sun, 22 Oct 2017 23:41:15 +0000
Subject: Req #14523 [Asn->Opn]: Additional parameter for str_repeat()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211829@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=14523&edit=1 ID: 14523 Updated by: kalle@php.net Reported by: ahristov at icygen dot com Summary: Additional parameter for str_repeat() -Status: Assigned +Status: Open Type: Feature/Change Request Package: Strings related Operating System: * PHP Version: * -Assigned To: francois +Assigned To: Block user comment: N Private report: N New Comment: Since francois' RFC has been Abandoned, I'm gonna unassign him this report Previous Comments: ------------------------------------------------------------------------ [2016-01-16 00:09:26] francois@php.net The 'Add cyclic string replacements' RFC (https://wiki.php.net/rfc/cyclic-replace) implements str_replace(search=<string>, replace=<array>). This RFC targets version 7.1. ------------------------------------------------------------------------ [2003-08-26 19:14:18] pollita@php.net oops, didn't notice this was assigned to me. I don't see that breaking BC since the current behavior is to convert $replace to a string if $search is not an array, hence str_replace('search',array('re','place'),'search my search for a search') would be a new condition to be handled. The only behavior I see this breaking is those who expect the above to return 'Array my Array for a Array' (which is a pretty esoteric behavior), would now get 're my place for a re' If you can get a concensus from php.internals, then it shouldn't be terribly hard to implement. ------------------------------------------------------------------------ [2003-05-31 11:25:42] andrey@php.net better will be done with : <?php $a = array("one", "two", "three"); $s = "[text]"; echo str_replace(array('text'), array_values($a), str_repeat($s, 10)); ?> but this doesn't work. So, reclassifying as feature request for str_replace(). "str_replace() should behave differently when string is used as [search] and array is passed as [replace]". Pollita, any comment on that. If that will break BC, then we will "won't fix" this. Thanks. ------------------------------------------------------------------------ [2001-12-14 14:14:36] ahristov at icygen dot com Is is possible third parameter to be added to str_repeat(). In case in the string there is a name of a variable and it is of type array the following code : foreach ($some_arr as $k =$v){ $output .= '<some_html>...'.$v.'....</some_html>'; } to be in one line $output = str_repeat('<some_html>...$some_arr ...</some_html>',count($some_arr),REPEAT_SUBSITUTE); Regards, Andrey Hristov ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=14523&edit=1

« previous php.bugs (#211829) next »