Re: How to test that an array is 'indexed' vs 'associative'



On Sat, 31 May 2008 15:57:07 +0200, Daniel Klein <danielk@xxxxxxxxxxxxxxxx> wrote:

I have a class constructor that accepts an array as the only argument. The
catch is that the array MUST be an 'integer-indexed' array, not an
'associative' array, because the index position has meaning.

How can I test for this in the constructor without having to traverse the
entire array and checking to make sure the keys are numeric and sequential?

Something like this maybe?
array_keys($array) === array_flip(array_keys($array))
--
Rik Wasmus
....spamrun finished
.



Relevant Pages