I'm frequently using the following to get the second to last value in an array:
$z=array_pop(array_slice($array,-2,1));
Am I missing a php function to do that in one go or is that the best I have?
end($array);
$z = prev($array);
This is more efficient than your solution because it relies on the array's internal pointer. Your solution does an uncessary copy of the array.
For numerically indexed, consecutive arrays, try $z = $array[count($array)-2];
Edit: For a more generic option, look at Artefecto's answer.