PHP Array current() Function

What is current() Function?

Explanation

The "current()" function returns the current element in an array. Based on the position of the pointer of an array, it displays the array element.

Syntax:


current(array)

In the above syntax "array" is the array from which the current element is to be displayed.

Example :


<?php
$b=array("1"=>"Grapes","2"=>"Apple","3" =>"Cherry");
echo current($b)."<br />";
?>
Result :

Grapes

In the above example the current() function returns the current element of the array "$b" that is "Grapes".

PHP Topics


Ask Questions

Ask Question