English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The current() function returns the current element in the array
current($array);
Each array has an internal pointer pointing to its 'current' element, which is initialized to the first element inserted into the array.
Serial number | Parameters and descriptions |
---|---|
1 | array(Required) It specifies an array |
It returns the current element in the array.
The current() function returns the current element of the array, as well as the current element returned after using functions such as next(), prev(), end(), etc.
<?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