Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130574 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 941051A00BC for ; Sun, 5 Apr 2026 10:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1775386348; bh=FZ1711RtoTS5qrpGijTAasIMHDXnkx0KuWLbXRsW9lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QjbQAFKx2TzOX6Gwj7hS10ILIzb4H7j6/r+PHLRkQKxQumqc2D/OH5tfq9NMt6pUH 0JahVzBxLi6f/lL1i3YhVpwz03pLT7Rn65BsJY81G0G2mzi+GBMskQyMIcpUA2wMsS /u00289dj3lqinYqpJ3qlfkslq0UxV0x3fZWM1PTN3sGV4YspZ0uxnFVfJjhVcSU+t 2I08ibxMH/JHFyI5T5LEjeaaE2VQq10Bzu5q0XUCL8QWjAnu5O8b0Pk+k6acosgS3X UZKMbxNK9c6tYrSnU0WoOttvh0iD4N8fxohRnUpn4VLvSU4FwNQU/G7GBKH0HFThZP VHd4/B/VMA4JQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CF752180068 for ; Sun, 5 Apr 2026 10:52:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FORGED_SPF_HELO, FREEMAIL_FROM,SPF_HELO_PASS,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sonic.asd.mail.yahoo.com (sonic-euwe4-0022.asd.mail.yahoo.com [34.2.86.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 5 Apr 2026 10:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1775386336; bh=FZ1711RtoTS5qrpGijTAasIMHDXnkx0KuWLbXRsW9lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=DuCCGPReCjCyl7xdzzO8bNwbJfXEAyNhLnP+YqnAURVl3PH8M44/R6djF+MIrJ/Y6bIf/A62Erdv6tUD+3vamenEusncVD5uud0JePC65u3RnOtji7Z4nFFrk9y0ekOXMG4BJopKlDjnHhoFaZw9Z4h2Udu3Pjh4ZlM+A5ZJZjg5Kf7VdSi4K5QiK3iwyiOV9UVdpkhhiKEJ/eG75GCY+Arq7pNByqz87oNjTg0NMyFj27G2kquRNYVToKE6PxCLpcL4kewVgbB4i+degdXhOuTl1r2yF83ZZTdES0Koh8Xh/3J5ZiLyn9/iFOvrUeRZ92I1VTLw+0BmGnvxpKlLWQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1775386336; bh=kA2XDzg8nTzsAa8LtCVpw57DsgMfIgUf3ykC8gm9sfJ=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=SykXuVU9J6lIZdbFVcu/VAuST0uVBvmL07VCeLnP9pYLhGmeESoJX38pwqaCmXwWg5nwGIhzZ+/+LLnB+V0iC/qZioHtl0j6pXxS8AAYiXQX1AiswbpLiy8sLO22kFJkQEGkV60VMV6vf3UEqtXB1m/CRDK7j5RW85QzwgbK9BHRzHGZCB5yINTRVgDOWIWu+OrWgTa8qRDvPM9/Q+qSaxTde9gxUOUOgkrSNQjNSmZ9C+EzVI8C4zKA4Z6OAiALHa67yuufzI4aIA4Fab7odPAWGP8e3zBhPWZnXJURp1HZf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AR1FLeKGvq_iGiN9A94WDD DxRfmhC606FUDGhcsbuPo_MNTVURVdoRiA43kQo5uNxFkJ4fHymIuUm068h7vB_DnKQkz4Ue14Vo urBsoLyOIn3FBacgTnIj5.HBY8lKbs8sKqspn4EX7jjcKVVvNhomr3he9_EXHcL9MoHjiBi0f3Nh mSMciVfFiaKoBDAoX._MTdrDDbVYZ8CTE0Ykaki4qgwoYqyIFJfVZyCg6MQeJ8qnNEJbm.eTioLx JsaF3kqlSec4HYSrbKbV2tqW5RiLn7H38JhupMSi_LZle0t8pKw4b5nsLHGZvGlq8xqvMHf2jz00 hAqrBFGuj8md.DNwp1Ib00hSqHKMa.FW.xM0E8Q1130opQ6hCkefTjmg.AXozRKpZzkM.2rhJzsE mGqc46N9B3iSpI066Hb89_5RVLnKDH_WsZ1FzbXVi.yNRDAomcWdLm5nFaQxEB1chpmHJC8HuhVE TAl2q8CX7Qz72QGL_8XljC8Fj.5.RQ5EuxPFeWQmgfGnUBAwEjfXlFOeVbLax6HyDJ_FsJIcIxc2 TDxtovdFCbKNcqnuYUnOKNqHATHrHwRVLaEokCqVelgvFco8Z2ZUgZPgfwE0dppegdzk1D_Sku4_ SqHMGAEbnl_v8rSrma92PRWjzuIKrbSTFU3W.eL5viO.ckbiNameOZl4zJYT0y1sz12EGIOwgbct HIrqobiT6AxW7L2bcPl6rTngzv8rJukxK3BB7iGsaFUZMsJKTZdBxeMk10r0T4gi.kjDcUnGomtp jK5VvcgwljVvcsjg3DbLpay3vWDMUi7O00pjHboCUwlWg35pcFI9ilvcOTDWGCjAEw5v3JmHRAOz SzmmNeZc5eA0Fs5oGDMVHu2UmXSj2Mxa9izaVAG5wv3a3OYYJjumgRnVpB17CnnGX1Jxw6HJ8VPp 6nrErPS8u8vZcIqySqw-- X-Sonic-MF: X-Sonic-ID: 351dfc97-5735-49d4-8ae9-7e2d3d54964c Received: from sonic.gate.mail.ne1.yahoo.com by mail-asdoutdeli-p-cin-euwe4-prod-sonicconsumer-svc-101 with HTTP; Sun, 5 Apr 2026 10:52:16 +0000 Received: from dip145.lsn.ir2.yahoo.com ([87.248.99.154]) by hello (SMTP) with SMTP ID 2f8fc7c5068a2dc004e3404d95bab60d; Sun, 05 Apr 2026 10:52:13 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Message-ID: <1775385960072.803756451.2349920337@yahoo.de> To: barel.barelon@gmail.com Cc: PHP internals Subject: Re: [PHP-DEV] [RFC] [Discussion] array_get and array_has functions Date: Sun, 05 Apr 2026 10:52:12 +0000 In-Reply-To: References: X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.9.3970.47 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 From: hanskrentel@yahoo.de (Hans Krentel) On Sunday 05 April 2026 11:43:03 (+02:00), Barel wrote: > On Sun, 5 Apr 2026 at 10:13, Hans Krentel wrote: >=20 > > > > On Saturday 04 April 2026 16:06:21 (+02:00), Barel wrote: > > > > > Hi, > > > > > > I would like to open the discussion on my proposal to add two small, > > > focused array functions for retrieving and checking nested array = elements > > > using dot notation. > > > > > > This is the link to the RFC: > > > https://wiki.php.net/rfc/array_get_and_array_has > > > > > > This is the link to the proposed implementation: > > > https://github.com/php/php-src/pull/21637 > > > > > > Thanks!! > > > > Thank you very much! That=E2=80=99s very interesting, so I have to ask = right away: > > Is there a specific reason to limit this to strings, integers, and null= for > > arrays, rather than also allowing arrays or iterables? > > > > This reminds me of JSON Pointers (RFC 6901), which can usually be = easily > > mapped as an iterable with string keys, which can then be accessed via = the > > holder variable, similar to the foreach example you already describe = in > > your RFC. > > > > If these two functions supported passing an array/iterable with the > > traversal keys as a second parameter, this would be advantageous, since= the > > JSON pointer would then not need to be recoded into dot notation, but = only > > (if not already done) sliced and passed as an array as the second = parameter. > > > > That's why I'm asking. > > > > Interestingly, JSON Pointer solves the =E2=80=9Cnull problem=E2=80=9D = by prefixing the > > zero or more reference tokens (keys) with a slash =E2=80=98/=E2=80=99, = and it supports all > > seven types of JSON values without limiting itself to just JSON arrays = or > > objects. This is just food for thought: array_... are clearly array > > functions, so this =E2=80=9Crestriction=E2=80=9D is likely intentional.= In PHP, however, I > > can also imagine iterables that resemble what you=E2=80=99ve already = described in > > your RFC, and from there it=E2=80=99s not far to the holder object we = see in JSON > > and JSON Pointer. So please don=E2=80=99t confuse my = =E2=80=9Crequest=E2=80=9D regarding > > arrays/iterables with the first parameter; it=E2=80=99s simply about = passing the > > key as a keys, which is a small improvement over dot notation. > > > > With arrays in PHP, users will likely prefer the non-standard, more = custom > > dot notation, and that=E2=80=99s perfectly fine. I saw many people = asking for this > > in the early days of Stack Overflow, and if Symfony/Laravel have it as > > well, that=E2=80=99s just another strong indication of such a = preference. > > > > Thanks again for your RFC > > > > > > --hakre > > > > P.S. Work on the RFC documentation for JSON Path finally began in 2020,= > > and it was published in February 2024. The standard has its roots in = PHP > > and JavaScript, and perhaps it=E2=80=99s time for PHP to expand its = standard > > library with such features at the same pace we did with JSON. Your RFC > > seems well-suited for this purpose. Thanks again. > > >=20 > Thanks for your comments. Someone else already suggested allowing arrays > for the $key parameter and I am considering it, I think it will probably = be > a good addition Yes, I agree, and I suggest we also consider _iterable_ as part of this = discussion. Thank you Carlos as well for your work on these functions. --hakre