note 97221 deleted from language.types.array by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Apr 2010 20:35:37 +0000 |
| Subject: | note 97221 deleted from language.types.array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168045@lists.php.net to get a copy of this message | ||
Note Submitter: userb at exampleb dot org
----
<?php
// this
$a = array( 'color' => 'red',
'taste' => 'sweet',
'shape' => 'round',
'name' => 'apple',
4 // key will be 0
);
// is completely equivalent with
$a['color'] = 'red';
$a['taste'] = 'sweet';
$a['shape'] = 'round';
$a['name'] = 'apple';
$a[] = 4; // key will be 0
$b[] = 'a';
$b[] = 'b';
$b[] = 'c';
// will result in the array array(0 => 'a' , 1 => 'b' , 2 =>
'c'),
// or simply array('a', 'b', 'c')
?>
There is a mistake in this Example ;)
$a[] = 4; // key will be 0
It wont be 0, it will be 1 ($a[0] is already set)