Best way to get last element of an array w/o deleting it?

reoomjnSolhyx

New Member
Ok,I know all about \[code\]array_pop()\[/code\], but that deletes the last element. What's the best way to get the last element of an array without deleting it?EDIT: Here's a bonus:\[code\]$array = array('a' => 'a', 'b' => 'b', 'c' => 'c');\[/code\]or even\[code\]$array = array('a', 'b', 'c', 'd');unset($array[2]);echo $array[sizeof($array) - 1]; // Output: PHP Notice: Undefined offset: 2 in - on line 4\[/code\]
 
Back
Top