Re: An array curiosity....

From: Date: Mon, 26 Jan 2004 14:57:58 +0000
Subject: Re: An array curiosity....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175762@lists.php.net to get a copy of this message
On Mon, Jan 26, 2004 at 08:50:51AM -0600, Jay Blanchard wrote: > Out of curiosity, and because I have never noted this in other > languages, why doesn't an 'open' comma at the end of an array throw any > kind of error? Is it because the comma denotes another element in the > array even if nothing is their? For example > > $arrBadInfo = array( > 'stuff ', > 'morstuff', > ); > > does not throw an error - even syntactical - This is as a convenience to programmers. Often arrays have things added or removed as you're coding -- not having to worry about removing a trailing comma for an element that is now the last one, or adding one to previous elements when adding items to the list is a small but useful timesaver. Perl does this as well. I'm not sure which other languages do, but I like it. -- [ joel boonstra | gospelcom.net ]

« previous php.general (#175762) next »