Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130111 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 AA01A1A00BC for ; Fri, 20 Feb 2026 17:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1771609470; bh=MbQB08cPiMHOxE/ujZPU3zZSMkoDXnBpwaJ5dS0wtjM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FzSjLMTwPamHkGAusV49VIkb2opDe0rHFV0MmmAJXw1E7GK7Ol83dX7dyaizjr8rn UTYI8jWpeb+Yxc5C3dlgzbvAK4/mjYoCezkTgTRzUupKT5lz4846/K+Zt/JdYly1GT JRX8ZtgsZzQlr839ttsgV9G09yogAv6zgjLeioIzZ0BjvKm6bq4Lu7G9KWaixkuZVQ jmsWEsz6OIqdY84Vrgz7SyU4b8QQDFTevxp/wSB+FKrgqGUmh07YkXxs84pgSsM7fz iEdCRCbUxXCLq5aopq4GW8H5plhtAbDuAFe1ErTVw+cY2SyrZsjTrKFVbaRiT/5Mew QTqyDdugio7Ng== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 65DF6180080 for ; Fri, 20 Feb 2026 17:44:29 +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.9 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 17:44:29 +0000 (UTC) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-5069ad750b7so19299791cf.2 for ; Fri, 20 Feb 2026 09:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771609463; cv=none; d=google.com; s=arc-20240605; b=K776TfhgT7S42XvehxzYWgr+l1V5kDfY0fnNQUZGbLfV7y83hVW6fch7tcSEkxOZjR 1lAHAOUYGDz9R4CbGpxsd4DVE+8H2HyZnpaO4VxQpMi9qSJRH0iGXHVQw+zxLPuvbaSe ChPdzY+YuoDdIfnhi3vhjY8wrn877Z4ulZx+7VmVg+C22RpjZeTXXTQ8Zns1TZkKzrkU kBITCUSZTTMkvncJg8NeFikN+HGQ8ve4X6mTQzg7cFQ3961vb+MUEBVUOX7WSZanS4wq Kr7IAeY0Sn2gVU2IfwEafeXxt09WP9IuncFI0Ra6u01oghLE2kzLFHUtpq6jTy6Ybh2a txRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=M+5Ppa0VyGk33waycwZjZ43mmzh8q3AW2U4B0Nvzk4c=; fh=lrZituD9CH8dMkGLrD+X7bJBFaO4A80Qz6nm/O89S+o=; b=f6Nd+x9X2nQ/JtoYMkpuzeYIvyiv8xNmwMVBD7F8EQZUG/ql20aqtUuy1rqepXxl79 LJd+nEq2Q8IXRk8nUUeyhr8FRMdmj1m0F6Iqb3Y2fvXDWVtKkBU1Yg2wmGgAjEhbPihA JGsyLhgSFBNFo9oHchtGaKYqIIo4ijAkuLgUaYr+QwIUOhWcHrDuh5V96zN+C/6J+qJX 4HLUnUanSMCNktgmGWS+A4CCDX5y9/XVeMJbe9gFriZsZPeYXjw0TAx/7avL8yNusePk BQ5u5OnFZQA0NJXId++ACPrZurPiR+fIfbENY9e40Sp4E0y4KDUt8gOeWMkoCOYKriub 4GZQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771609463; x=1772214263; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=M+5Ppa0VyGk33waycwZjZ43mmzh8q3AW2U4B0Nvzk4c=; b=SKSUI6Uy+7xGhceNTA9cnvrOzcz6DTogQDYwe/lryqDxtMyeTdbBObILYzE3pM8HLh NkBCbHqBe3SuiSwcKxLrb5aGoM9Fwm56g94tJkk8SNN/D5na8fVb2fk6jPfqIx9u0ZfL 1tL3N/WAqXfOe5zPJ+m9/UfV/uOhmU2KaS/E1V1XEMtkvsVRyO4xtWXwqRtj0lcA+s9N EkIOQK/jnBtV8kBLtVZw9IjZgtHQSIur5Pe2VQx7JKBy8tK/xSSAesSMmK0dd7k2il+2 3N7UDBqgClgVIW4Pl+8VnVXyUwHJdNNbK8L5gtBgf74ErzCVtuMHSPf2Wu7Lo1TV8alW yszw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771609463; x=1772214263; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=M+5Ppa0VyGk33waycwZjZ43mmzh8q3AW2U4B0Nvzk4c=; b=WBET3HHv93VHbT4Q7uY3Mo6hrFdhApq2XhSy3A8eBuUwsowxubV9CWfx+d4FTsWSV4 uk06+LnH5xTbrkO2MHgF5XH2baxVU6HhA9yXWE3P67A7Db8J4ASEMTVnew6jZGAkmZPH 5z9SoWWUIA/lc1Evfac2/F816DLH7Ysv6Rs6MnloeZPDkewsW/MS03YydgJ/sRBj68iB wF8PSOSi+qHZcsCEaq+0/wzRDy79Sfatn8zfgUrqYy8nOF6MoQY5UQZ266aneeURbs68 Zmn667lirBUZVjEGkrgo76iV2r5wmk1kX8nbo98p5I5p42U/1bk5mCasLNxru5uFbZAb D/9A== X-Gm-Message-State: AOJu0YzAkwZlZBGYzJUsAtkOCaD1zVKTDL+CcCjZOqVcemow37ACAa0P ZbuzVQWrWRCz3Fdmd+Q4kCjbDocPbV0PaKJlMCo+K9Iqe2xybWvQ4u7x9Sz2TDWpaY2/hPGOxDL 7//c3kRdyFZKjVPqBYrGTiAyE+8jzGWZlaA== X-Gm-Gg: AZuq6aKgzJbbMmzpjjsk2feW/U+AG+9X3RbKOAVcuKspd08JTjwy+iYePYyxW2KXzsq Xa2S2Y1e74H/K8Sqfhs1KpWL1xCgO6702uPTSj6BHOzBcIaPQ7WJ/nX7TqXyjpBi6rjwmXa3xSM VzKqIGOR13/e1nAhtO+KEWHiH/bN3Iiv8m5ijD6wn503btHTrCbq1bCyxq2sXBM+MngreSwrqyl BPPWJ19VG7nZrvMRs+EIfdVI3/Sy07LNrwMXnexcK19iXUMGs7JceAa9mX9OfvsPf+sCTrRSYbe OKtplG4hp5U8BGqsoWwfT+UbAoLPC9i1zMkg+H4dQtlewcW9ktbGryQVv4VDkvgtNQ++wZDWnw= = X-Received: by 2002:a05:690e:4149:b0:649:4906:770a with SMTP id 956f58d0204a3-64c788d2821mr473847d50.8.1771609071767; Fri, 20 Feb 2026 09:37:51 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <3ACF2D3E-0376-4033-8CAA-84FAD83E2A69@gmail.com> In-Reply-To: <3ACF2D3E-0376-4033-8CAA-84FAD83E2A69@gmail.com> Date: Fri, 20 Feb 2026 23:07:38 +0530 X-Gm-Features: AZwV_QjPMYMLaRxHcewIV6rh6Wux49xzxWCwrEW0HqS8jr4RHWs8QLuQYtC2RGQ Message-ID: Subject: =?UTF-8?Q?Re=3A_=5BPHP=2DDEV=5D_=5BRFC=5D_array=5Fonly=28=29_and_array=5Fexcept=28=29_?= =?UTF-8?Q?=E2=80=93_Utility_functions_for_array_key_filtering?= To: Claude Pache Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000006755ac064b44e17f" From: arshidkv12@gmail.com (Muhammed Arshid KV) --0000000000006755ac064b44e17f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Thanks for the feedback. 1. Yes, *array_intersect_key() *and *array_diff_key() *can be used today, but the RFC proposes dedicated functions for better readability, less boilerplate, and potentially better performance and lower memory usage by avoiding temporary arrays. 2. Good point about naming. Making the key-filtering behavior explicit (e.g., *array_only_keys* and *array_except_keys*) improves clarity and avoids confusion. On Fri, 20 Feb 2026, 3:38=E2=80=AFpm Claude Pache, = wrote: > > > Le 20 f=C3=A9vr. 2026 =C3=A0 10:25, Muhammed Arshid KV 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 suppor= t > 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 > > --0000000000006755ac064b44e17f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Thanks for the feedback.

1. Yes, array_intersect_key() and array_diff_key() can be= used today, but the RFC proposes dedicated functions for better readabilit= y, less boilerplate, and potentially better performance and lower memory us= age by avoiding temporary arrays.

2. Good point about naming. Making the key-filtering behavior exp= licit (e.g., array_only_keys and array_except_keys) improves = clarity and avoids confusion.

On Fri, 20 Fe= b 2026, 3:38=E2=80=AFpm Claude Pache, <claude.pache@gmail.com> wrote:


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

= Hello Internals,

I would like to propose a new RFC titled arr= ay_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 functi= ons allow selecting or excluding specific keys from an array.=C2=A0

S= imilar helpers are commonly used in frameworks, and adding native support w= ould improve readability and consistency in userland code.

Summary:

=E2=80=A2 array_only() returns a new array containing only the specifi= ed keys.
=E2=80=A2 array_except() returns a new array excluding the specified keys.<= br> =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 principl= e of the RFC is interesting to me, as it is a situation I encounter from ti= me to time. Two remarks:

1. It may be interesting = to compare with currently available solutions. Currently, I use =C2=A0`arra= y_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 nam= e 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_k= eys`.

=E2=80=94Claude

--0000000000006755ac064b44e17f--