echo current(array);
Example
$my_array=array("First One", "Second One", "Third One", "Fourth One", "Fifth One" );
echo current($my_array); // Output first one
current reads the value of the present internal pointer or cursor of the array. We can move the internal pointer to next element by using next$my_array=array("First One", "Second One", "Third One", "Fourth One");
echo current($my_array); // Output first one
next($my_array);
echo current($my_array);// Output Second One
$my_array=array("First One", "Second One", "Third One", "Fourth One", "Fifth One" );
echo key($my_array); // Output is 0
$my_array=array("First One", "Second One", "Third One", "Fourth One", "Fifth One");
echo current($my_array); // Output : First One
echo next($my_array); // Output : Second One
echo next($my_array); // Output : Third One
echo prev($my_array); // Output : Second One
echo end($my_array); // Output : Fifth One
echo reset($my_array); // Output : First One
$arr = array("apple", "banana", "cherry");
echo current($arr); // Output: apple
next($arr);
echo current($arr); // Output: banana
prev($arr);
echo current($arr); // Output: apple
$arr = array(
array("name" => "John", "age" => 30),
array("name" => "Jane", "age" => 25)
);
echo current($arr)["name"]; // Output: John
next($arr);
echo '<br>';
echo current($arr)["name"]; // Output: Jane
Explanation:Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.