Problem Description
Ok,
I know all about [`array_pop()`][1], but that deletes the last element. How to get the last element of an array without deleting it?
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
[1]: http://www.php.net/array_pop
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?