English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The end() function returns the last element of the array
end(array $array);
The end() function advances the internal pointer of the array to the last element and returns its value.
Serial Number | Parameters and Description |
---|---|
1 | array(Required) It specifies an array that is passed by reference, because it will be modified by this function. This means that you must pass a real variable, not an array returned by the function, because only real variables can be passed by reference. |
Returns the value of the last element, or FALSE if the array is empty.
<?php $transport = array('foot', 'bike', 'car', 'plane'); $mode = current($transport); print "$mode<br />"; $mode = next($transport); print "$mode<br />"; $mode = current($transport); print "$mode<br />"; $mode = prev($transport); print "$mode<br />"; $mode = end($transport); print "$mode<br />"; $mode = current($transport); print "$mode<br />"; ?>Test and see‹/›
Output result:
foot bike bike foot plane plane