Re: How to test that an array is 'indexed' vs 'associative'
- From: "Rik Wasmus" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Sat, 31 May 2008 16:03:12 +0200
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
.
- References:
- How to test that an array is 'indexed' vs 'associative'
- From: Daniel Klein
- How to test that an array is 'indexed' vs 'associative'
- Prev by Date: Re: How to test that an array is 'indexed' vs 'associative'
- Next by Date: Re: using fopen() in write mode is failing
- Previous by thread: Re: How to test that an array is 'indexed' vs 'associative'
- Next by thread: Re: How to test that an array is 'indexed' vs 'associative'
- Index(es):
Relevant Pages
|