TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   $ary['x']= array('a'=>'y')... VS $ary['x']['a']= y... (http://www.talkphp.com/advanced-php-programming/4859-ary-x-array-y-vs-ary-x-y.html)

PiEhPi 08-17-2009 08:44 AM

$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.

Salathe 08-17-2009 10:39 AM

Not a whole lot. The second is more typing I suppose.

EGYG33K 08-17-2009 10:43 AM

the 2nd is more lines but in the memory they are the same

PiEhPi 08-17-2009 12:11 PM

Thanks both ;).
Resolved.

Wildhoney 08-17-2009 02:04 PM

And readability, I suppose. It's a personal preference, but I prefer to format my arrays like so:

php Code:
$ary['x'] = array
(
    'a' => 11111,
    'b' => 22222,
    'c' => 33333
);


All times are GMT. The time now is 02:12 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0