current next reset function in php_PHP tutorial

WBOY
Release: 2016-07-20 11:02:01
Original
879 people have browsed it

$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
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445391.htmlTechArticle$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 one position next($array)...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template