时间:2021-07-01 10:21:17 帮助过:4人阅读
- php
- $temp[0] = "richmond";
- $temp[1] = "tigers";
- $temp[2] = "premiers";
- for($x=0;$x<count($temp);$x++)
- {
- echo $temp[$x];
- echo " ";
- }
- ?>
然而另外一种更加节省代码的方式是:
- php
- $temp = array("richmond", "tigers", "premiers");
- foreach ($temp as $element)
- echo "$element ";
- ?>
foreach 还能输出文字下标:
- php
- $temp = array("club" => "richmond",
- "nickname" =>"tigers",
- "aim" => "premiers");
- foreach ($temp as $key => $value)
- echo "$key : $value ";
- ?>
以上就是PHP关联数组在数据库中的相关使用方法。
http://www.bkjia.com/PHPjc/446373.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446373.htmlTechArticle我们在操作数据库的时候,需要用到 下面我们看一个基本的数字格式的数组遍历: ? php $temp[0]="richmond"; $temp[1]="tigers"; $temp[2]="premiers"; for...