php foreach循环的问题,一直循环两次(将两种索引都检索一遍)…………

foreach($temp_authorityas$key=>$value){$_SESSION[$key]=$value;echo"thisiskey:".$key."... foreach ($temp_authority as $key => $value) {
$_SESSION[$key] = $value;
echo "this is key :".$key." and this is value : ".$value." ;<br/> ";
$i++;
}

echo 是我用来进行输出验证的,然后得到了如下结果(在网页里面显示形式):
this is key :0 and this is value : 10 ;
this is key :ID and this is value : 10 ;
this is key :1 and this is value : super ;
this is key :charactor and this is value : super ;
this is key :2 and this is value : 9 ;
this is key :check_in and this is value : 9 ;
this is key :3 and this is value : 9 ;
this is key :elder_manage and this is value : 9 ;
this is key :4 and this is value : 9 ;
this is key :charge and this is value : 9 ;
this is key :5 and this is value : 9 ;
this is key :assistant and this is value : 9 ;
this is key :6 and this is value : 9 ;
this is key :clerk_manage and this is value : 9 ;
this is key :7 and this is value : 9 ;
this is key :warehoust and this is value : 9 ;
this is key :8 and this is value : 9 ;
this is key :meals and this is value : 9 ;
this is key :9 and this is value : 9 ;
this is key :specialsevice and this is value : 9 ;
this is key :10 and this is value : 9 ;
this is key :datas and this is value : 9 ;
this is key :11 and this is value : 9 ;
this is key :room_manage and this is value : 9 ;
this is key :12 and this is value : 9 ;
this is key :system and this is value : 9 ;
展开
 我来答
amwih001
2015-09-09 · TA获得超过2.3万个赞
知道大有可为答主
回答量:1529
采纳率:100%
帮助的人:677万
展开全部
因为你查询数据库返回数组时用的是返回包含关联和数字索引的数组(MYSQL_BOTH)

建议使用mysql_fetch_assoc来遍历结果集
追问
非常感谢您的回答O(∩_∩)O哈哈~

另外,请问 fetch_arry 所取回的结果集是怎样子存储的呢? 就是像我所打印出来的那样,{0:'10' , ID:'10' , 1:'super' , charactor:'super' , ………………}这样子存储的吗?
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式