PHP current() Function
The current( ) function is an inbuilt function of PHP, and it is used to return the value of the current element in an array. This function was introduced in PHP 4.0.
Syntax
mixed current ( array $array );
Parameters
Parameter | Description | Is Compulsory |
---|---|---|
array | Specifies the array to use. | Compulsory |
Return values
The current( ) function returns the value of the current element in an array or false on empty elements.
PHP Example
<?php
$array = array("shorat", "udemy", "udacity", "coursera", "edureka");
print_r(current($array));
?>
Output
shorat
PHP Example
<?php
$array = array("javatpoint", "udemy", "udacity", "coursera", "edureka");
next($array);
print_r(current($array));
?>
Output
udemy
PHP Example
<?php
$array = array("javatpoint", "udemy", "udacity", "coursera", "edureka");
next($array);
next($array);
print_r(current($array));
?>
Output
udacity
PHP Example
<?php
$array = array("javatpoint", "udemy", "udacity", "coursera", "edureka");
end($array);
print_r(current($array));
?>
Output
edureka