Re: Re: does array_slice not work on multidimensional arrays?
| From: | Ashley Sheridan | Date: | Sat, 08 Aug 2009 15:05:20 +0000 |
| Subject: | Re: Re: does array_slice not work on multidimensional arrays? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296477@lists.php.net to get a copy of this message | ||
On Sat, 2009-08-08 at 09:00 -0600, John Butler wrote:
> >> It seems clear to me, but do you also agree that my evidence is that
> >> array_slice() does NOT work on multi-dimmed arrays on v.4.3.9?
> >> Here is the evidence:
> >>
> >> this:
> >>
> >> var_dump($BuildPerUniqueDateArray);
> >> echo"\n\n~~~~~~~~~~~~~\n\n";
> >> array_slice($BuildPerUniqueDateArray, 1, 2);
> >> var_dump($BuildPerUniqueDateArray);
> >
> > It seems clear to me that you are dumping /the same/
> > array twice.
>
>
> Aha. I see now. I had to *assign* the results of the array_slice
> to a [new] array and then use that ...
> (trying to do something and expecting the results to "stick" even
> without assigning them to a var, bites me every week or so. I'll get
> it through my old habits-from-other-languages skull eventually.)
>
> Thank you Nisse,
>
> -Govinda
>
It is annoying working with arrays sometimes, as some functions work on
the actual array, while others return the results of working on the
array without changing anything. Is there any particular reason for
that?
Thanks,
Ash
http://www.ashleysheridan.co.uk