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
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…