PHP » Arrays » end()

Syntax:
mixed end(array array)
array
Array for which the pointer should be set to the end.

Sets an array pointer to the last element.

The internal pointer of an array is set to the last element with this function. end() also returns the last element.

Examples

Code:
<?php

$array1 = array("one", "two", "three");

print end($array1) . " " . current($array1);

?>
Output:
three three
Explanation:

The last element of an array is printed by using the end() function. To show that the pointer has also moved, the element returned by current() is also printed.

See Also: