Re: Two new functions array_first() and array_last()
| From: | Michael Cordover | Date: | Tue, 17 Oct 2023 16:06:08 +0000 |
| Subject: | Re: Two new functions array_first() and array_last() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121352@lists.php.net to get a copy of this message | ||
On Tue, Oct 17, 2023, at 05:10, Levi Morrison via internals wrote:
> It's true that sentiment may have shifted in this time. However, a
> common argument at that time still stands:
null is not a good
> sentintenal for failure because the value inside the array very well
> could have been null.
What about a signature like:
```php
array_first(array $array, mixed $value_if_missing = null);
```
That would let you specify your own sentinel (or default) where appropriate, without losing the
convenience of this function.
mjec