The end() function sets the internal pointer of an array to its last element
Syntax
end(arr)
Parameters
arr − The specified array
Return
The end() function returns the value of the last element in the array, on success. It returns FALSE, if the array is empty.
Example
The following is an example −
<?php $os = array('windows', 'mac', 'linux', 'solaris'); echo end($os); ?>
Output
The following is the output −
solaris
Example
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"; ?>
Output
The following is the output −
one two two six six