Re: Re: Proposal for a new array function
| From: | Rowan Collins | Date: | Thu, 11 Feb 2016 11:58:10 +0000 |
| Subject: | Re: Re: Proposal for a new array function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91199@lists.php.net to get a copy of this message | ||
Christian Wenz wrote on 11/02/2016 09:17:
On Mon, Feb 8, 2016 at 09:32 AM, Matthew Setter wrote:This is why the exact specification - and name - of any proposed function needs to be considered carefully. In many cases, what you actually want to verify is "is this a pure list / vector?" in which case you might *want* that array to return false. A naive version of which would be "$arr === array_values($arr)".The approach I took was this: return array_keys($arr) !== range(0, count($arr) - 1);FWIW, this might not work for arrays with missing indices like [0 => 'a', 2 => 'b'] I personally would appreciate a function like you proposed.