Re: Associative Arrays

From: Date: Fri, 20 Jun 2008 02:59:04 +0000
Subject: Re: Associative Arrays
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-275663@lists.php.net to get a copy of this message
At 6/19/2008 07:36 PM, Robert Cummings wrote:
    54321 => array(
      'mail' => 'asdf@asdf.net',
      'companyName' => 'Asdfu Corp.',
    ),
);
This is the right PHP syntax, except that you've got an extraneous comma before the closing parenthesis of each array that's going to throw a parse error.
Actually that's allowed (and by design too) :) Yep, it's there to primarily simplify generated PHP code. Additionally, it sure makes commenting out chunks simple since you don't need to comment out the preceding comma if commenting out the last entry.
Thanks. I could have sworn I'd gotten parse errors on that. Damned cross-language memory leakage... I've gotten into the habit of writing comma-delimited lists like so:
        (item
        ,item
        ,item
        ,item
        );
which works for functions with long parameter lists and SQL field lists as well as arrays. Paul

« previous php.general (#275663) next »