Re: Two new functions array_first() and array_last()

From: Date: Tue, 17 Oct 2023 16:19:30 +0000
Subject: Re: Two new functions array_first() and array_last()
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-121353@lists.php.net to get a copy of this message
> 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. This is a problem that should be addressed in your application. ``` array_first($arr) ?? $initial ``` I personally think we should make the effort to write it this way and not have to support initial values ​​at the language level. Regards. Saki

« previous php.internals (#121353) next »