Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105781 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40691 invoked from network); 23 May 2019 21:54:31 -0000 Received: from unknown (HELO lb3-smtp-cloud9.xs4all.net) (194.109.24.30) by pb1.pair.com with SMTP; 23 May 2019 21:54:31 -0000 Received: from [IPv6:2001:983:6fc5:1:e1df:136a:c447:2bf0] ([IPv6:2001:983:6fc5:1:e1df:136a:c447:2bf0]) by smtp-cloud9.xs4all.net with ESMTPA id TsywhEylfsDWyTsyyhPcdJ; Thu, 23 May 2019 21:02:29 +0200 To: Nikita Popov Cc: "G. P. B." , PHP Development References: Message-ID: Date: Thu, 23 May 2019 21:02:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: nl Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfAOrUWPw2qqYaymdH+zdtnqF8h3tQfQTRy1rRo5718Qxj71v0lASpTiJgV4R7qc6s4o+xOi0gOWVeRdhSRqRNghpUrfGSCgzqR0FWh7wAc4TfyupUhLw ctMrwathCavT7zLoINq3L+c4asUcGjrYARk7qM+OM29Sv5e2ZKf/CjrWBDwD076L9uoQaLa3emtWcEaT7bIALtvwLLv6hIxkcDkBPKM1Gh51DX1qXMZRbdqo 0B1leYxpdXhleQmeaseOH67n4KOWD989GBFOrs4Mfv/k5s658zUaLHxjzBhUpmpXFHITYO8DP9TDGdkptD+fVEebvoAmpKVhqOcxtTR43Ug= Subject: Re: [PHP-DEV] Calling array_merge / array_merge_recursive without arguments From: d.takken@xs4all.nl (Dik Takken) On 21-05-19 10:29, Nikita Popov wrote: > This one makes sense in theory, because array_map(null, ...$arrays) is a > way to perform a zip operation in PHP. Unfortunately there is an ugly > special case if there is only a single array, which makes this not actually > usable in practice, unless you know that there are at least two arrays. As > such, accepting zero arrays wouldn't be very useful unless we also want to > fix that issue (PHP 8 maybe?) Ah, I overlooked that edge case. Indeed, array_map() would require more fixing than I anticipated. I guess it is out of scope for the type of fix we are discussing. >> array_diff() & friends > > array_intersect() & friends > > > These look like good candidates for allowing a single arg. For array_intersect(), I was actually considering to allow zero arguments. The use case I have in mind is to determine the common elements in a set of zero or more arrays, like this: array_intersect(...$arrays) If that would just return an empty array when $arrays is empty, no additional empty check is needed and the above would do what I intuitively expect it to do.