php如何输出多维数组? 10
$families=array("news"=>array("id"=>"1","name"=>"新闻管理","url"=>"/#1","submenus"=>array...
$families = array
(
"news" => array(
"id"=>"1",
"name"=>"新闻管理",
"url" =>"/#1",
"submenus"=>array(
"category"=>array(
"id"=>"1",
"name"=>"新闻类别",
"url" =>"/#1",
),
"add"=>array(
"id"=>"2",
"name"=>"新闻添加",
"url" =>"/#1",
),
"update"=>array(
"id"=>"3",
"name"=>"新闻更新",
"url" =>"/#1",
),
)
),
"products" => array(
"id"=>"2",
"name"=>"产品管理",
"url" =>"/#1",
"submenus"=>array(
"category"=>array(
"id"=>"1",
"name"=>"产品类别",
"url" =>"/#1",
),
"add"=>array(
"id"=>"2",
"name"=>"产品添加",
"url" =>"/#1",
),
"update"=>array(
"id"=>"3",
"name"=>"产品更新",
"url" =>"/#1",
),
)
),
); 展开
(
"news" => array(
"id"=>"1",
"name"=>"新闻管理",
"url" =>"/#1",
"submenus"=>array(
"category"=>array(
"id"=>"1",
"name"=>"新闻类别",
"url" =>"/#1",
),
"add"=>array(
"id"=>"2",
"name"=>"新闻添加",
"url" =>"/#1",
),
"update"=>array(
"id"=>"3",
"name"=>"新闻更新",
"url" =>"/#1",
),
)
),
"products" => array(
"id"=>"2",
"name"=>"产品管理",
"url" =>"/#1",
"submenus"=>array(
"category"=>array(
"id"=>"1",
"name"=>"产品类别",
"url" =>"/#1",
),
"add"=>array(
"id"=>"2",
"name"=>"产品添加",
"url" =>"/#1",
),
"update"=>array(
"id"=>"3",
"name"=>"产品更新",
"url" =>"/#1",
),
)
),
); 展开
展开全部
$arr3=array(
"m"=>array("mm"."mmm","mmmm"),
"j"=>array("jj"."jjj","jjjj"),
"s"=>array("ss"."sss","ssss")
);
这个怎么输出呢?不用var_dump和print_r,用for循环或者foreach。。。。谢谢了
"m"=>array("mm"."mmm","mmmm"),
"j"=>array("jj"."jjj","jjjj"),
"s"=>array("ss"."sss","ssss")
);
这个怎么输出呢?不用var_dump和print_r,用for循环或者foreach。。。。谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function printArr ($families){
if(is_array($families)){
foreach( $families as $key => $val){
if(is_array( $val)) printArr( $val);
else {
echo $key.'==='.$val;
}
}
}
}
if(is_array($families)){
foreach( $families as $key => $val){
if(is_array( $val)) printArr( $val);
else {
echo $key.'==='.$val;
}
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-01-12
展开全部
print_r()这个就可以啊还有var_dump()也是可以的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$arr = array();
foreach($families as $key=>$val){
$arr[$key]=$val;
}
var_dump($arr);
foreach($families as $key=>$val){
$arr[$key]=$val;
}
var_dump($arr);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
foreach
字数够没。
字数够没。
更多追问追答
追问
请写个列子!谢谢
追答
foreach ($families as $arr) {
echo $arr["name"];
}
看文档就有,真够懒的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询