PHP: How to pop the last item off the array without actually removing it from the array?

arrays, php

Solution

Try `end`

<?php

$fruits = array('apple', 'banana', 'cranberry');
echo end($fruits); // cranberry

?>

Problem

Possible Duplicate: PHP get index of last inserted item in array I have an array or variable length and would like a quick and easy way to know the value of the last item in the array (without actually removing it from the array). How can I pop the last item off the array without actually removing it from the array?

Original source

Related problems