September 2001
Intermediate to advanced
768 pages
32h 45m
English
mixed end(array array) Sets the internal array pointer to the last element of the array and returns that element’s value.
Returns:
Contents of the last array element
Description:
Sets the internal array pointer to the last element of array and returns the value of that element. This can be used to quickly seek to the end of an array; for instance, if you need to iterate through an array backwards but don’t want to reverse the array using something like array_reverse().
Version:
PHP 3, PHP 4
See also:
current() key() next() prev() reset()
Example:
$my_array = array("a", "b", "c", "d", "e"); echo "The last element of the array is: " . end($my_array); for ($i = count($my_array); $i >= 0; ... |
Read now
Unlock full access