faqts : Computers : Programming : Languages : PHP : Function Libraries : Arrays

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 13 people (100%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

Any better way to get the last element of an array than $array[array_pop(array_keys($array))]?

Feb 14th, 2002 11:22
Ben Udall, Haig Evans-Kavaldjian, http://www.php.net/manual/en/function.end.php


Yes.  You can use the end() function which returns the last element of an
array.
$last = end($array);