$array=array('step one','step two','step three','step four'); //Define an array
echo current($array)."
n"; //Return the first element of the array
next($array); // Move the array pointer back one place
next($array); // Move the array pointer back one place
echo current($array)."
n"; //Return the current element of the array, the third value
reset($array); //The pointer points to the first value of the array
echo current($array)."
n"; //Return the first value of the array
//
$info=array('red','blue','green'); //Define array
while($result=current($info))
{
echo $result;
echo "
";
next($info);
}
//
$array=array(
'fruit1'=>'apple',
'fruit2'=>'orange',
'fruit3'=>'grape',
'fruit4'=>'apple',
'fruit5'=>'apple'); //Define array
while($fruit_name=current($array)) //Loop to get the current value of the array
{
if($fruit_name=='apple') //If the current value is apple
{
echo key($array).'
'; //Output the key name of the current value
}
next($array); //Move the array pointer down one step
}