Welcome to FindNerd. We are going to discuss the in-build functions in php to handle the pointer of the array. You can easily get the current pointer of the array by
using current() function, next function will advance the pointer of the array and prev function will move the pointer one element back. Please have a look.
<?php
$myArr = array('Deepak','Verma','Saharanpur','UP');
echo current($myArr);
echo '<br />' . next($myArr);
echo '<br />' . current($myArr);
echo '<br />' . prev($myArr);
echo '<br />' . current($myArr);
?>
result:
Deepak
Verma
Verma
Deepak
Deepak
In above example we created an array with four elements. you used the function current to get the current element, used the next fnction to move the pointer forward and prev function to move the pointer backward. In the end we used current to get
the current element. Hope this helps.
0 Comment(s)