qq_情歌只唱给你听_0
2017-07-07 17:38
首页[Home]
关于我们[Aboutus]
新闻中心[News]
公司新闻[Company]
通知[Notice]
产品列表[Product]
鞋子[Shoot]
衣服[Cost]
联系我们[Contactus]
把上面的导航内容转换成数组
array('Home'=>'首页','Aboutus'=>'关于我们','News'=>‘新闻中心','Company'=>'公司新闻') 后面你按着这个格式写吧
<table> <tr> <td>home</td> <td>首页</td> </tr> <tr> <td>News</td> <td>新闻中心</td> </tr> <tr> <td>Company</td> <td>公司新闻</td> </tr> </table>
这么嵌套吗?这体现不了层级关系啊。
<?php
$navigator = [
'Home'=>'首页',
'Aboutus'=>'关于我们',
'News'=>[
'News'=>'新闻',
'childs'=>[
'Company'=>'公司新闻',
'Notice'=>'通知'
]
],
'Preduct'=>[
'Product'=>'产品列表',
'childs'=>[
'Shoot'=>'鞋子',
'Cost'=>'衣服'
]
],
'Contactus'=>'联系我们'
];
function arr_foreach($arr){
foreach($arr as $key=>$value){
if(is_array($value)){
arr_foreach($value);
}else{
echo $value.'['.$key.']'.'<br>';
}
}
}
arr_foreach($navigator);PHP进阶篇
181960 学习 · 2668 问题
相似问题