NYCPHP Meetup

NYPHP.org

[PHP] Need to get last element of 2-dimensional array

Rasmus Lerdorf rasmus at php.net
Sat Sep 28 20:38:37 EDT 2002


Well, your nasty parse error is because you have 2 opening ( and 3 closing
) on that line.

A quick way to get the very last element of a 2-d array is to use:

  echo end(end($idArray));

-Rasmus

On Sat, 28 Sep 2002, Phil Powell wrote:

> The following produced a rather nasty parse error:
>
> echo ($idArray[0][sizeof($idArray[0])]));
>
> I have a 2-dimensional array $idArray that I must obtain the LAST element of that 2-dimensional array.. how do I do it?
>
> Thanx
> Phil
>




More information about the talk mailing list