On Wed, 25 Dec 2002, @ Nilaab wrote: > I have an multi-dimensional array called $cat_data, which is info extracted > from a MySQL DB. I want to retrieve the very last item of that array. How > would I do that? I know the first item can be retrieved by simply asking for > $cat_data[0][0], which contains an id number. But I can't figure out how to > get the last item in that same array -- $cat_data[x][0] where x is the last > item in the array.
Naturally, the index of last item of an array is one less than the total number of elements in the array. $num_elements = count( $cat_data ); $last_element = $cat_data[$num_elements-1][0]; // 0 being what you were seeking Cheers! ~Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php