From d8b6d2927901b7ab7727cce4c0ea74676b006e0e Mon Sep 17 00:00:00 2001 From: Torben Wilson Date: Wed, 5 Nov 2008 06:16:51 +0000 Subject: [PATCH] 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 --- language/types/array.xml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/language/types/array.xml b/language/types/array.xml index 4a6daa34fe..01139b71bf 100644 --- a/language/types/array.xml +++ b/language/types/array.xml @@ -1,5 +1,5 @@ - + Arrays @@ -597,26 +597,33 @@ var_dump((array) new B()); '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'). ?> ]]>