【php开源代码栏目提醒】:网学会员为需要php开源代码的朋友们搜集整理了4_15.php相关资料,希望对各位网友有所帮助!
<?php
//定义一个数组
$array = array("红色","绿色","黄色","蓝色");
//数组定义后,使用current()取得当前单元的值
$red = current($array);
//把数组内部指针向下移动一位
next($array);
//使用current()取得当指针指向单元的值
$green = current($array);
//把数组内部指针移动到最后一位
end($array);
//使用current()取得当指针指向单元的值
$blue = current($array);
echo "显示current()返回变量的结果:";
echo "$red $green $blue<br>";
//定义一个数组
$speed = array(50,120,260,320,400,520);
//使用each()移动指针,current()返回数组单元值
echo "1档的速度是".current(each($speed))."<br>";
echo "2档的速度是".current(each($speed))."<br>";
echo "3档的速度是".current(each($speed))."<br>";
echo "4档的速度是".current(each($speed))."<br>";
echo "5档的速度是".current(each($speed))."<br>";
echo "6档的速度是".current(each($speed))."<br>";
//重置数组指针
reset($array);
echo "使用each()遍历数组:";
while(list($key,$value) = each($array)){
echo "$key=>$value,";
}
?>
上一篇:
4_14.php
下一篇:
为定制而来 欧马可快递物流一体化解决方案抢滩苏浙沪