Re: [RFC] array_only() and array _except() – Utility functions for array key filteri ng
| From: | Tim Düsterhus | Date: | Sun, 22 Feb 2026 18:25:21 +0000 |
| Subject: | Re: [RFC] array_only() and array _except() – Utility functions for array key filteri ng | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130129@lists.php.net to get a copy of this message | ||
Hi
The same comments as with your other RFC apply here.
On 2/20/26 18:37, Muhammed Arshid KV wrote:
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.Can you elaborate on what you mean by “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.I don't think that
array_(only|except)_keys() is particularly clear. From the naming I would expect it to return the array keys / values (i.e. do the same as array_keys() and array_values() respectively).
Best regards
Tim Düsterhus