1、foreach遍历

$arr[] = array('first'=>green,'second'=>'yellow','third'=>'blue');

foreach($arr as $key=>$val){

     echo $key.'-'.$val;

     echo ' ';

}

输出结果:

first-green

second-yellow

third-blue

2、while-each遍历

$arr[] = array('first'=>green,'second'=>'yellow','third'=>'blue');

while($element = each($arr)){

     echo $element ['key'].'-'.$element [value].;

     echo ' ';

}

输出结果:

first-green

second-yellow

third-blue

2、while-list-each遍历

$arr[] = array('first'=>green,'second'=>'yellow','third'=>'blue');

while(list($key,$val) = each($arr)){

     echo $key.'-'.$val;

     echo ' ';

}

输出结果:

first-green

second-yellow

third-blue

注意:以上遍历中的each()函数,数组将记录当前元素,若要重新遍历数组,则要使用reset()函数重新设置数组指针到数组的开始处。

最新文章

  1. 小兔JS教程(三)-- 彻底攻略JS回调函数
  2. p/invoke碎片--对类的封送处理
  3. swift错误和异常处理
  4. flash builder关掉自动编译功能
  5. HTTP协议中状态码的应用
  6. [ASP.NET]asp.net Repeater控件的使用方法
  7. C#中结构体的声明
  8. linux 常用查找命令 小技巧
  9. 【转】ubuntu中的Wine详解
  10. HDU 3853 期望概率DP
  11. leetcode第33题--Search for a Range
  12. uitableview 关于键盘挡住输入框解决方法
  13. 高通msm8909耳机调试
  14. CentOS7中使用iptables
  15. cad2012卸载/安装失败/如何彻底卸载清除干净cad2012注册表和文件的方法
  16. oracle order by 排序
  17. response的contentType的类型值Response.ContentType
  18. synchronized(一)
  19. hdu 1880 魔咒词典 (字符串哈希)
  20. Metasploit 使用基础

热门文章

  1. 十天精通CSS3学习笔记 part2
  2. 给libpcap增加一个新的捕包方法
  3. Discuz! X论坛上传附件到100%自动取消上传的原因及解决方案
  4. Orchard入门:如何创建一个完整Module
  5. ASCII、UNICODE、UTF-8等关系
  6. Oracle表的建立条件
  7. html5之canvas画图基础
  8. Virtual Box 下Ubuntu桥接网络设置
  9. Coding源码学习第一部分(AppDelegate.m)
  10. Bootstrap<基础二十四> 缩略图