[RESOLVED] $ary['x']= array('a'=>'y')... VS $ary['x']['a']= y...
Hi,
What is difference/better between:
PHP Code:
$ary['x']= array('a'=>11111, 'b'=>22222, 'c'=>33333... );
VS
$ary['x']['a']= 11111;
$ary['x']['b']= 22222;
$ary['x']['c']= 33333;
...
? :)
Thanks for help.
Re: $ary['x']= array('a'=>'y')... VS $ary['x']['a']= y...
In the first statement you are explicitly initialising the array $ary and setting the 'x' element to an associative array.
In the second statement you are implicitly initialising the 'x' element of the $ary variable by setting individual elements in the associative array. Put the statement:
PHP Code:
error_reporting(E_ALL);
At the top of the script and remove the first line and you will see the Notice that is generated when you reference the 'x' element without first using $ary['x']=array();