Re: [VOTE] array_key_first(), array_key_last(), array_value_first(),array_value_last()

From: Date: Wed, 11 Jul 2018 23:04:36 +0000
Subject: Re: [VOTE] array_key_first(), array_key_last(), array_value_first(),array_value_last()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-102780@lists.php.net to get a copy of this message
Hi, CHU Zhaowei wrote:
I voted no. I don't think we have an agreement on dealing with non-existing value, and the way this RFC proposed, just returning null without any notice/warning, is wrong IMO. I know we already do this in other array_* functions, but we cannot keep making mistakes just because we already made same mistake. Regards, CHU Zhaowei
Hmm. Returning null with no warning makes perfect sense for keys, since null is not a valid key so there's no ambiguity, but for values it seems problematic. On that ground I've decided to change my vote to No for the value functions, but keep the vote for Yes for the key functions. Someone who wants such behaviour could always do ($array[array_key_last($array)] ?? null), I guess. -- Andrea Faulds https://ajf.me/

« previous php.internals (#102780) next »