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
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.