Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105774 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91000 invoked from network); 21 May 2019 16:10:02 -0000 Received: from unknown (HELO mail-vs1-f67.google.com) (209.85.217.67) by pb1.pair.com with SMTP; 21 May 2019 16:10:02 -0000 Received: by mail-vs1-f67.google.com with SMTP id o5so11116358vsq.4 for ; Tue, 21 May 2019 06:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rd3iQxuGTWL6lZ9o03lK2L8RciGgaty1ajp1zNQLm4s=; b=pNm95f4FvyDjDroU/YxC4HQAqpmbusCTeHER/nDzudYimP+ugnvcZG7SMo2fhjQNTo Mo5zOMvFpqjPeSJQiUKnpKUV0zV9hnGwSCDW6XzqpOHSQ7Vk7ml7y0O9lX3jYiH6h1z8 UXSBFSevdhrIF2tS2R++IX2LDFlnKVqPjsV4I7oeMSNlxGss495r1FhX5z+o5xCVnuGU Nb9ncUxJhvhmWz0JwdWSKe3eWYOpX38owI+qIWLkP8Zx7Qos/8AC1StiOt0tFHQXW8dP 6qiHqNTtSZpOn1DeaXzCE0TwuusOih7eyM6Jlx3YeH3GanIqVG3nDb1kcEeGzyvjOuli 3vtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rd3iQxuGTWL6lZ9o03lK2L8RciGgaty1ajp1zNQLm4s=; b=eIry3HCE0QAxNJSPGHzzIjoG2ElRNbCD5sw9m1PY27Zbqan96efs0dGYXa71eos8Ip h0JHsy1QtuMbL5dK3TCjjqsb7lU8Qg4ZqoDmhicWd6BocaKzb24Zuz89sTAn4gV1sOPE qOC0hrm6xTBa5LYqMJlRcyZzwXRafOD20BG+SiuMuzbNXdxolE+aq4bvZMW3AUDQFq5S Nl5DwCYYyGJCEIWVPr4uIoNQ35hewmK8LpEAcl8Z6Jsbx+u3n4tjVTT5cu4agT+8f00X a3WnmsPLzHkbebma82XBlVAGFq2GfaUcslwgWzqNWPB480gjVmk5KUWNOyitKHNu6F91 6twA== X-Gm-Message-State: APjAAAVgoab3KUnSQjs6fEe8PyHy+2yiqKJzU1V+Y2EzYrWqHMd9//EF 31e28tR9FCMp3vUihMm7BJtUJAfmJj3w+1uC4Vo= X-Google-Smtp-Source: APXvYqx0t/ucLObwmAGK8lQ/8iaVKme8kNFTYjeF2MH6/6+MuqrELOcdxGLPVPC5XQAkxXwy+YoR6hTXWPtkPR0VWL4= X-Received: by 2002:a67:330f:: with SMTP id z15mr10932752vsz.12.1558444646017; Tue, 21 May 2019 06:17:26 -0700 (PDT) MIME-Version: 1.0 References: <61bc4844-9888-00fb-bff0-336784f5450b@gmx.de> In-Reply-To: <61bc4844-9888-00fb-bff0-336784f5450b@gmx.de> Date: Tue, 21 May 2019 15:17:16 +0200 Message-ID: To: "Christoph M. Becker" Cc: Nikita Popov , Dik Takken , PHP Development Content-Type: multipart/alternative; boundary="0000000000008731fa058965abd5" Subject: Re: [PHP-DEV] Calling array_merge / array_merge_recursive without arguments From: george.banyard@gmail.com ("G. P. B.") --0000000000008731fa058965abd5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 21 May 2019 at 13:40, Christoph M. Becker wrote= : > On 21.05.2019 at 12:54, G. P. B. wrote: > > > On Tue, 21 May 2019 at 10:29, Nikita Popov wrote= : > > > >> On Sat, May 18, 2019 at 9:37 PM Dik Takken wrote: > >> > >>> Good point. I did a quick scan of the source code and came up with a > >>> list of possible candidates for a similar treatment: > >>> > >>> array_map() > >> > >> 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 wan= t > to > >> fix that issue (PHP 8 maybe?) > > > > I'm not sure I totally understand the edge case, moreover this isn't > > currently documented. > > Mind sharing an example or explaining a bit more in detail such that I > can > > update the documentation? > > If you pass only a single array to array_map(NULL, =E2=80=A6), you don't = get an > array of arrays, but a single flat array, see . > > -- > Christoph M. Becker > Thanks Christoph for the example didn't even really know that you could use null as a callback. So I suppose the "correct" behaviour wanted for array_map with NULL as a callback is to always return an array of arrays instead of a flat one when there is only one, correct? I think I'll add a small note to the doc and an example showing the difference in behaviour as it seems pretty berried in the examples (the 4th one to be precise atm). Best regards George P. Banyard --0000000000008731fa058965abd5--