Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130103 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 72DF91A00BC for ; Fri, 20 Feb 2026 10:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1771582136; bh=lowIN/zILvVf10XSSIMOc6QvC6+NJutF2OMpdt3iQ9s=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=Oyf/hLlvWLJxN5++mkS0P7lTIj5iKbfgClDs1yxv/igeMr61xfZfb5V8MuqI52U4G VFEKOcYwQBdNN2M8TCuQb2fljQjz5ZcqFzsqt2zEd4dkig9Atc+Y2PiDHWT4crbr3L Kjs2p3Q3QC5LKGl+W7U7QBOWAfp3LiyKYC+w89JmRU6mwK/r0gitigFsUirenjz6Qy Ws0SYoiTzmX2QUWyc/lB0TVRmBLQVJtGluGXfUT2TAPgHJJ7eNTICD/K6Cy4sJQ+LO /Tq/6IE1QAFuf9+vpwac6CtburnqgqrvFZN6N2znTP+K7E2RRZ0+o60wNo5nZTBSqK Tb9nt4/s2B99A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 27CC7180083 for ; Fri, 20 Feb 2026 10:08:56 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 ; Fri, 20 Feb 2026 10:08:55 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4806ce0f97bso15332605e9.0 for ; Fri, 20 Feb 2026 02:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771582130; x=1772186930; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=1pEUT5EwfaLYh64fXc5Fbuyc3NRju8O8V5Vl2x185cE=; b=kUI4sYW9NsjZydIQZJLXtTjUjzVOn8XoFssEnyo9FZ69WkCZ0NMJbs7DPgs7IxFFnV 7z4JZyTk0Cc91DKs4zhrTH0PlzDUAIsvJ6HlexupZ+7P6QDN5twvlm7bJRAr9jEYr5Zh 3ytF0ctPWPeGsDoDAo3gEEeuWhtWAe3RsNyXscC7ChzBoHkFZQ07d2s1g1PGIRdTu4+O 1S1c3MW4msGrVU8gjhGnq/dLl0FW3/Tl+gFLQECkwFSxE29o9eTx2ULlBvGSerZ7xFMO t9VlcvE+a285kKr+Zd2gsVy1hb9UE0UMqRWa9xN42pVCjQyUkJikh/XeXRSTQW4kj8ET /GtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771582130; x=1772186930; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1pEUT5EwfaLYh64fXc5Fbuyc3NRju8O8V5Vl2x185cE=; b=mlPrasQCmAyKY6FHK8iXVgGDn+xTx2FKOKQY7Z6z/sdyYzBghbOjpc3oCoo4ZhcCw5 a5qOB8oHIgxvu7BTZr3jvylmZKaVZM/llDafTPrP7hOmSAUuxZ74Wwti3lkRP7n4WO8t pga2CJlvDA7qCbHgbhlbifeOn7b8dRAnfClkPb36Ye3H/3yKHDmOOy7GexzXfpDzaLvf GaREP1no+18MvcPjdaaoNpxh1lorhf3RM9Qh1gc7fi8cXnYDnw2jYkzSkVQGtvn4zRuk o6kNlfTPLM3o5F1fYsT0ouUnKozKINCqdZrYIV8B4mSXvgenxlOZKCchcdcbAvDzMOKf wd3g== X-Gm-Message-State: AOJu0Yzn9togV1pNmzLAue/xf3XmnGo6wHiD/F5GhKoZdKJKGH+Pj1+n 7F3BwPZVTatIcNrMYhnjX/ZoIsIC/aVkwdVD/SQxdOeshposaYbms4GT X-Gm-Gg: AZuq6aJ/rpv5ss3VdP0sg+f8e9/Yt3yC+sVCQSfXINyV86uPeaiOKVAvPuCHXz6akX6 yE46vlX4kS2I58ON9nMuSVwFwWwXD75AUN8YRUxN0tQJiGIZ0IJ0nKdVukoOO58J97STXSWrFAN ThFQra/5KnYC38tIirDpc403NQjCcny+S42EojgkeVKR6AhmvgySBbddZ0+JhxEefECMAL9P+DO B68tHOCR3fBZuegErnQRGdBIlSNrZMz+OinLb0d9KmVchT/qSzq9+le/N0AcCqyVM6VXKgW0kDN diy6v9gKUdCVd3QioRl++gSmZqusOzF0+7miQwxF1eBrPdlya5D/3W1WiIsa8Nlvk8VLBRlffsu WujiRyR0izZvxiz6+NOq3szGvID+so97v7Ydw0cxd3qOAq4zHQNB7Lk51fR4uaXM0alLpUbBZvY xB0NtYh8xwLhjrxVOtX+IdWF2dmH4mNK14RZn14GYu9p1sCQ== X-Received: by 2002:a05:600c:5296:b0:477:abea:9028 with SMTP id 5b1f17b1804b1-48398a42672mr135634725e9.6.1771582129577; Fri, 20 Feb 2026 02:08:49 -0800 (PST) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac82f7sm60272461f8f.28.2026.02.20.02.08.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Feb 2026 02:08:49 -0800 (PST) Message-ID: <3ACF2D3E-0376-4033-8CAA-84FAD83E2A69@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_A511EC05-AF27-46ED-B8EF-D9D08490D1E1" Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: =?utf-8?Q?Re=3A_=5BPHP-DEV=5D_=5BRFC=5D_array=5Fonly=28=29_and_ar?= =?utf-8?Q?ray=5Fexcept=28=29_=E2=80=93_Utility_functions_for_array_key_fi?= =?utf-8?Q?ltering?= Date: Fri, 20 Feb 2026 11:08:38 +0100 In-Reply-To: Cc: internals@lists.php.net To: Muhammed Arshid KV References: X-Mailer: Apple Mail (2.3864.400.21) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_A511EC05-AF27-46ED-B8EF-D9D08490D1E1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 20 f=C3=A9vr. 2026 =C3=A0 10:25, Muhammed Arshid KV = a =C3=A9crit : >=20 > Hello Internals, >=20 > I would like to propose a new RFC titled array_only() and = array_except(). >=20 > RFC: https://wiki.php.net/rfc/array_only_except = > This RFC proposes adding two utility functions to the PHP core: >=20 > =E2=80=A2 array_only(array $array, array $keys): array > =E2=80=A2 array_except(array $array, array $keys): array >=20 > These functions allow selecting or excluding specific keys from an = array.=20 >=20 > Similar helpers are commonly used in frameworks, and adding native = support would improve readability and consistency in userland code. >=20 > Summary: >=20 > =E2=80=A2 array_only() returns a new array containing only the = specified keys. > =E2=80=A2 array_except() returns a new array excluding the specified = keys. > =E2=80=A2 Original array is not modified. > =E2=80=A2 Works with associative and numeric keys. > =E2=80=A2 No impact on SAPIs or on OPcache. >=20 > I would appreciate feedback and suggestions from the community. > If there is general agreement, I plan to move the RFC forward. >=20 > Thanks, > Muhammed Arshid KV >=20 Hi, The principle of the RFC is interesting to me, as it is a situation I = encounter from time to time. Two remarks: 1. It may be interesting to compare with currently available solutions. = Currently, I use `array_intersect_key` and `array_diff_key` when I need = the semantics of proposed `array_only` and `array_except`: ```php array_intersect_key($data, ['id' =3D> null, 'email' =3D> null]); ``` 2. I think that the name of the new functions ought to make evident that = we are filtering on keys and not on something else. I suggest: = `array_only_keys` and `array_except_keys`. =E2=80=94Claude --Apple-Mail=_A511EC05-AF27-46ED-B8EF-D9D08490D1E1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 20 f=C3=A9vr. 2026 =C3=A0 10:25, Muhammed Arshid = KV <arshidkv12@gmail.com> a =C3=A9crit :

Hello = Internals,

I would like to propose a new RFC titled = array_only() and array_except().

RFC: https://wiki.php.net/rfc/array_only_except

This RFC proposes adding two = utility functions to the PHP core:

=E2=80=A2 array_only(array = $array, array $keys): array
=E2=80=A2 array_except(array $array, array $keys): array

These = functions allow selecting or excluding specific keys from an = array. 

Similar helpers are commonly used in frameworks, and = adding native support would improve readability and consistency in = userland code.

Summary:

=E2=80=A2 array_only() returns a new = array containing only the specified keys.
=E2=80=A2 array_except() returns a new array excluding the specified = keys.
=E2=80=A2 Original array is not modified.
=E2=80=A2 Works with associative and numeric keys.
=E2=80=A2 No impact on SAPIs or on OPcache.

I would = appreciate feedback and suggestions from the community.
If there is general agreement, I plan to move the RFC = forward.

Thanks,
Muhammed Arshid KV


Hi,

The = principle of the RFC is interesting to me, as it is a situation I = encounter from time to time. Two remarks:

1. It = may be interesting to compare with currently available solutions. = Currently, I use  `array_intersect_key` and `array_diff_key` when I = need the semantics of proposed `array_only` and = `array_except`:

```php
array_intersect_= key($data, ['id' =3D> null, 'email' =3D> = null]);
```

2. I think that the name = of the new functions ought to make evident that we are filtering on keys = and not on something else. I suggest: `array_only_keys` and = `array_except_keys`.

=E2=80=94Claude
= --Apple-Mail=_A511EC05-AF27-46ED-B8EF-D9D08490D1E1--