The end() function sets the internal pointer of an array to its last element
end(arr)
arr − The specified array
The end() function returns the value of the last element in the array, on success. It returns FALSE, if the array is empty.
The following is an example −
<?php $os = array('windows', 'mac', 'linux', 'solaris'); echo end($os); ?>
The following is the output −
solaris
Let us see another example −
<?php $a = array('one', 'two', 'three', 'four', 'five', 'six' ); echo current($a)."\n"; echo next($a)."\n"; echo current($a)."\n"; echo end($a)."\n"; echo current($a)."\n"; ?>
The following is the output −
one two two six six