大家帮助我看下这个二维数组怎么通过foreach循环打印

chb89888404 2009-08-16 12:43:22

<?php
$array=array(
array("id"=>"1","name"=>"王永平","date"=>"2008-8-7"),
array("id"=>"2","name"=>"韩文丽","date"=>"2008-8-8"),
array("id"=>"3","name"=>"曹雅丽","date"=>"2008-9-9"),
array("id"=>"4","name"=>"董盼红","date"=>"2008-8-10"),
);

?>

大家帮助我看下这个二维数组怎么通过foreach循环打印出里面所有“name”对应的值,我昨天试了一直没有成功,谢谢
...全文
627 9 打赏 收藏 举报
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ms_X0828 2009-08-17
输出name:

foreach ($array as $a){
echo $a["name"]."<br/>";
}

输出所有信息:
foreach ($array as $a){
foreach ($a as $val){
echo $val." ";
}
echo "<br/>";
}
  • 打赏
  • 举报
回复
llj480028 2009-08-17
foreach($array as $key=>$value){
foreach($value as $key1=>$value1)
print $value1;print "<br>";
}
测一下看看,应该可以的~
  • 打赏
  • 举报
回复
llj480028 2009-08-17
foreach($array as $key=>$value){
foreach($value as $key1=>$value1)
print $value1;print "<br>";
}
测一下看看,应该可以的~
  • 打赏
  • 举报
回复
llj480028 2009-08-17
foreach($array as $key=>$value){
foreach($value as $key1=>$value1)
print $value1;print "<br>";
}
测一下看看,应该可以的~
  • 打赏
  • 举报
回复
wzftop 2009-08-17
foreach ($array as $arr)
{
echo $arr['name']."<br/>";

}
  • 打赏
  • 举报
回复
CunningBoy 2009-08-17
foreach($array as $v1){
echo $v1['name']."\r\n";
}
  • 打赏
  • 举报
回复
Ehlonna 2009-08-16
foreach ($array as $v) {
echo $v['name'] . "<br />";
}
  • 打赏
  • 举报
回复
kondykuang 2009-08-16
"a1"=> 粘贴了忘了改
  • 打赏
  • 举报
回复
kondykuang 2009-08-16
<?php
$array=array(
array("id"=>"1","name"=>"王永平","date"=>"2008-8-7"),
array("id"=>"2","name"=>"韩文丽","date"=>"2008-8-8"),
array("id"=>"3","name"=>"曹雅丽","date"=>"2008-9-9"),
array("id"=>"4","name"=>"董盼红","date"=>"2008-8-10"),
);

?>

//你这我也不知道怎么用foreach遍历。好像只能一个一个打。
最好写成这样。
$arrayname=array(
"a1"=>array("id"=>"1","name"=>"王永平","date"=>"2008-8-7"),
"a1"=>array("id"=>"2","name"=>"韩文丽","date"=>"2008-8-8"),
"a1"=>array("id"=>"3","name"=>"曹雅丽","date"=>"2008-9-9"),
"a1"=>array("id"=>"4","name"=>"董盼红","date"=>"2008-8-10"),
  • 打赏
  • 举报
回复
相关推荐
<%dim num1,rndnum Randomize Do While Len(rndnum)<4 num1=CStr(Chr((57-48)*rnd+48)) rndnum=rndnum&num1 loop verifycode=rndnum %>