Re: How to test that an array is 'indexed' vs 'associative'
- From: Michael Fesser <netizen@xxxxxx>
- Date: Sat, 31 May 2008 17:21:30 +0200
..oO(Daniel Klein)
On Sat, 31 May 2008 07:01:07 -0700 (PDT), jpedrobarbosa@xxxxxxxxx wrote:
my opinion is dont check it. just retreve the values with
"array_values"
I wish it was that easy but associative arrays are like 'hash tables' so the
values will not be in the proper order.
Even "numeric" arrays are just a hash table. There's no built-in order
of array elements. By default all elements are stored and retrieved in
the order in which they are inserted:
$foo = array(2 => 'foo', 1 => 'bar');
var_dump($foo);
If you want a "correct" order, you always have to use one of the various
array sorting functions.
Micha
.
- References:
- How to test that an array is 'indexed' vs 'associative'
- From: Daniel Klein
- Re: How to test that an array is 'indexed' vs 'associative'
- From: jpedrobarbosa
- Re: 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: Creating a simple hitcounter for PHP web pages. (saves to files)
- Next by Date: Re: able to upload 28 meg file, yet php.ini limits posts to 10 megs. What is up with that?
- 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
|