Ok,
I know all about array_pop()
, 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:
$array = array('a' => 'a', 'b' => 'b', 'c' => 'c');
or even
$array = array('a', 'b', 'c', 'd');
unset($array[2]);
echo $array[sizeof($array) - 1]; // Output: PHP Notice: Undefined offset: 2 in - on line 4