Tiny update to make the examples of array definition functionally

equivalent. Addresses Bug #46251.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@268325 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Torben Wilson 2008-11-05 06:16:51 +00:00
parent 38b003a6ae
commit d8b6d29279

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<sect1 xml:id="language.types.array">
<title>Arrays</title>
@ -597,26 +597,33 @@ var_dump((array) new B());
<programlisting role="php">
<![CDATA[
<?php
// this
// This:
$a = array( 'color' => 'red',
'taste' => 'sweet',
'shape' => 'round',
'name' => 'apple',
4 // key will be 0
4 // key will be 0
);
// is completely equivalent with
$b = array('a', 'b', 'c');
// . . .is completely equivalent with this:
$a = array();
$a['color'] = 'red';
$a['taste'] = 'sweet';
$a['shape'] = 'round';
$a['name'] = 'apple';
$a[] = 4; // key will be 0
$b = array();
$b[] = 'a';
$b[] = 'b';
$b[] = 'c';
// will result in the array array(0 => 'a' , 1 => 'b' , 2 => 'c'),
// or simply array('a', 'b', 'c')
// After the above code is executed, $a will be the array
// array('color' => 'red', 'taste' => 'sweet', 'shape' => 'round',
// 'name' => 'apple', 0 => 4), and $b will be the array
// array(0 => 'a', 1 => 'b', 2 => 'c'), or simply array('a', 'b', 'c').
?>
]]>
</programlisting>