php数组相关函数,遍历数组

1、php数组相关函数

bool sort ( array &array [, int sort_flags] ) 对数组进行排序

bool natsort ( array &array ) 用自然排序法对数组进行排序

int count ( mixed var [, int mode] ) 计算数组中单元数组或对象中属性的个数, sizeof 的同名函数

输出数组

PHP中输出数组的函数有比较多,常用的有

bool print_r ( mixed expression [, bool return] )

2、从数组中遍历读取数据

foreach (array_expr as $value)

{ statement    }

foreach (array_expr as $key=>$value)

{ statement   }

提取每个键/值对,直到获得所有项或满足某些内部条件为止

3、PHP数组包含两个项,keyvalue,可以通过key来获取相应的value,其中key又可以是数值和关联的,$array[0],$array[one]

原文:

http://blog.csdn.net/greyls/article/details/5707579

http://www.phpk8.com/article/e5/135.html

http://www.phpstudy.net/a.php/13.html

posted @ 2012-10-17 00:07  浪里飞  阅读(270)  评论(0编辑  收藏  举报