Christian Wenz wrote on 11/02/2016 09:17:
On Mon, Feb 8, 2016 at 09:32 AM, Matthew Setter wrote:
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.
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)".
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php