note 97221 added to language.types.array
| From: | userb at exampleb dot org | Date: | Thu, 08 Apr 2010 20:32:08 +0000 |
| Subject: | note 97221 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168044@lists.php.net to get a copy of this message | ||
<?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)
----
Server IP: 69.147.83.197
Probable Submitter: 84.166.13.48
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/97221
Del: integrated -- https://master.php.net/note/delete/97221/integrated
Del: useless -- https://master.php.net/note/delete/97221/useless
Del: bad code -- https://master.php.net/note/delete/97221/bad+code
Del: spam -- https://master.php.net/note/delete/97221/spam
Del: non-english -- https://master.php.net/note/delete/97221/non-english
Del: in docs -- https://master.php.net/note/delete/97221/in+docs
Del: other reasons-- https://master.php.net/note/delete/97221
Reject -- https://master.php.net/note/reject/97221
Search -- https://master.php.net/manage/user-notes.php