This is an old revision of the document!
PHP RFC: array_first() and array_last()
- Version: 0.9
- Date: 2025-03-31
- Author: Niels Dossche, nielsdos@php.net
- Status: Draft
- First Published at: https://wiki.php.net/rfc/array_first_last
Introduction
The elevator pitch for the RFC. The first paragraph of this section will be slightly larger to give it emphasis; please write a good introduction.
Proposal
All the features and examples of the proposal.
To paraphrase Zeev Suraski, explain how the proposal brings substantial value to be considered for inclusion in one of the world's most popular programming languages.
Remember that the RFC contents should be easily reusable in the PHP Documentation.
If applicable, you may wish to use the language specification as a reference.
Backward Incompatible Changes
If anyone defined array_first() or array_last() in their global scope, then they need to guard it now with function_exists or throw it away because of the name clash. Although it should be noted that the global namespace is normally reserved for PHP's usage.
Proposed PHP Version(s)
Next PHP 8.x, i.e. PHP 8.5 at the time of writing.
RFC Impact
To Existing Extensions
These two new functions are added to ext-standard, where array_key_first and array_key_last also live.
Unaffected PHP Functionality
No changes to existing PHP functionality.
Proposed Voting Choices
2/3rd yes/no vote.
Patches and Tests
TODO
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged into
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
- a link to the language specification section (if any)
References
TODO
Prior Work
* Proposal from 2023 discussing these new functions: https://externals.io/message/121313 * RFC that introduced array_key_first() and array_key_last(): https://wiki.php.net/rfc/array_key_first_last
Rejected Features
None yet.