English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The end() function returns the last element of the array
end ( $array );
The end() function moves the array's internal pointer 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 you must pass an actual variable, not an array returned by a function, because only actual 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