Re: [PHP] difference between indexed and associative arrays?
- Date: Wed, 5 Apr 2017 14:01:14 +0530
- From: Jigar Dhulla <jigar.tidus@xxxxxxxxx>
- Subject: Re: [PHP] difference between indexed and associative arrays?
On Wed, Apr 5, 2017 at 1:37 PM, Narcis Garcia <informatica@xxxxxxxxx> wrote:
> As I understand, an associative array is exactly same as indexed array
> but with an additional "property": the key.
> El 04/04/17 a les 23:54, Jeffry Killen ha escrit:
> > Is there a function that will produce the difference between indexed and
> > associative arrays, without actually testing for string or integer
> > (Although I realize that arrays can be mixed string and integer indeces.)
> > Thank you for time and attention.
> > JK
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Indexed array has key property too, difference is that key are always
indexed (as name suggest).
$a = [2 => 'foo', 4 => 'bar', 6 => 'baz'];
$a = 'foo1';
$a = 'bar1';
Here keys(2 and 4) stays as is and keys(1 & 3) will be skipped. And next
key will largest key value + 1.