The current() function returns the current element in an array.
Syntax
current(arr)
Parameters
arr − The specified array. Required.
Return
The current() function returns the value of the current element in an array.
Example
The following is an example −
<?php $arr = array("one", "two"); echo current($arr); ?>
Output
The following is the output −
one
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"; ?>
Output
The following is the output −
one two two