$array=array('step one','step two','step three','step four'); //定義一個數組
echo current($array)."
n"; //返回數組第一個元素
next($array); //數組指標後移一位
next($array); //數組指標後移一位
echo current($array)."
n"; //返回數組當前元素,第三個值
reset($array); //指標指向數組第一個值
echo current($array)."
n"; //返回數組第一個值
//
$info=array('red','blue','green'); //定義數組
while($result=current($info))
{
echo $result;
echo "
";
next($info);
}
//
$array=array(
'fruit1'=>'apple',
'fruit2'=>'orange',
'fruit3'=>'grape',
'fruit4'=>'apple',
'fruit5'=>'apple'); //定義數組
while($fruit_name=current($array)) //迴圈擷取數組當前值
{
if($fruit_name=='apple') //如果當前值為apple
{
echo key($array).'
'; //輸出當前值的鍵名
}
next($array); //數組指標下移一步
}
http://www.bkjia.com/PHPjc/445391.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445391.htmlTechArticle$array=array(step one,step two,step three,step four);//定義一個數組 echo current($array). n;//返回數組第一個元素 next($array);//數組指標後移一位 next($array)...