On Thu, 17 Jun 2004 10:33:39 +0200 (CEST)
Derick Rethans <[EMAIL PROTECTED]> wrote:

> On Thu, 17 Jun 2004, Jason Garber wrote:
> 
> > Hello,
> >
> > In PHP4 and PHP5 the following syntax works fine (note the last
> > comma):
> >
> > array
> > (
> >      1 => 'bob',
> >      2 => 'sam',
> > );
> >
> >
> > Is being able to have a comma at the END of an array definition a
> > supported feature, or an undocumented feature that should not be
> > used?
> 
> It's an undocumented feature AFAIK.

There is user note about it here:
http://www.php.net/manual/en/function.array.php

-----
10-May-2003 03:53 
Similarly to a comment by stlawson at sbcglobal dot net on this page:
http://www.php.net/basic-syntax.instruction-separation

It is usually advisable to define your arrays like this:
$array = array(
     'foo',
     'bar',
);

Note the comma after the last element - this is perfectly legal.
Moreover, it's best to add that last comma so that when you add new
elements to the array, you don't have to worry about adding a comma
after what used to be the last element.

$array = array(
     'foo',
     'bar',
     'baz',
);
-----

But yes, perhaps it should be mentioned in the doc, that the comma at
the end is ok.

---
WBR,
Antony Dovgal aka tony2001
[EMAIL PROTECTED] || [EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to