$list[] = array('upid'=>'1','title'=>'公司新闻','list'=>array('id'=>'3','title'=>'公司新闻标题测试!','intime'=>'2009-29-5'));foreach ($list as $a){ echo $a['upid'] .'-'. $a['title']; foreach ($a['list'] as $b){ echo $b['title']; }} 这样写对嘛?为什么输出不对呢?
$list = array('upid'=>'1','title'=>'公司新闻','list'=>array('id'=>'3','title'=>'公司新闻标题测试!','intime'=>'2009-29-5'));foreach ($list as $v=>$a){ /*echo $a['upid'] .'-'. $a['title']; foreach ($a['list'] as $b){ echo $b['title']; }*/ if($v=='list') { foreach ($a as $b) { echo $b; } } else { echo $a; }} 这样就行了..
$list = array('upid'=>'1','title'=>'公司新闻','list'=>array('id'=>'3','title'=>'公司新闻标题测试!','intime'=>'2009-29-5'));foreach ($list as $v=>$a){ if($v=='list') { foreach ($a as $b) { echo $b; } } else { echo $a; }} 不一定是最好的.但是可以运行.好好理解喔