mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
38b003a6ae
commit
d8b6d29279
1 changed files with 13 additions and 6 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue