Re: Two new functions array_first() and array_last()
| From: | Saki Takamachi | Date: | Wed, 18 Oct 2023 02:30:04 +0000 |
| Subject: | Re: Two new functions array_first() and array_last() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121367@lists.php.net to get a copy of this message | ||
I thought of it after sending the email, so I'll post it again. By combining my two ideas, I
think I can come up with a smarter proposal.
```
array_first(array $array, int|string &$key = null)
```
If you want to accurately determine whether an array is empty or not, you can satisfy your request
by checking if the key is null. Users who do not think accurate determination is necessary can omit
the second argument.
And if you also want a key, it can fulfill that request as well.
Regards.
Saki