Re: Arrays: Comma at end?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2012-02-07 at 12:26 -0800, Micky Hulse wrote:

> On Tue, Feb 7, 2012 at 12:19 PM, Micky Hulse <rgmicky@xxxxxxxxx> wrote:
> > Yah, ditto! :D
> 
> $s = 'foo,bar,';
> print_r(explode(',', $s));
> 
> The output is:
> 
> Array
> (
>     [0] => foo
>     [1] => bar
>     [2] =>
> )
> 
> That's one instance where I know you have to be cautious about the
> trailing delimiter.
> 
> I know, this is all noob stuff... Sorry. :D
> 


That's because it's not an array you've got the trailing delimiter on,
it's a string. We were talking about commas on the end of the last
element in the array, like:

$var = array(
    'foo',
    'bar',
);

That only contains two elements, and won't have a hidden 3rd at any
time.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux