On Wed, 18 Oct 2023 at 17:05, Robert Landers <landers.rob...@gmail.com> wrote:
> > This is simply not true, 0 is not always the first key in a list, > especially after filtering it. Hence there is a need for this function > in the first place. Just to clarify this point: If 0 is not the first key, then it's not a list. After filtering a list, you get an array that may or may not be a list: https://3v4l.org/VegUr Regardless, to add my 2 cents, I'd keep things simple and vote for this signature: array_first(array $array): mixed array_last(array $array): mixed returning the first/last element, or `null` if the array is empty. Or, alternatively: array_first(array $array, mixed $default = null): mixed array_last(array $array, mixed $default = null): mixed returning `$default` if the array is empty. Both look fine to me. - Benjamin