关于数组循环的一个问题
$config['menu']['member']['coption'] = '搜索';
$config['menu']['member']['sub'][0]['caption']='百度';
$config['menu']['member']['sub'][0]['url']='http://www.baidu.com';
$config['menu']['member']['sub'][1]['caption']='谷歌';
$config['menu']['member']['sub'][1]['url']='http://www.google.com';
$config['menu']['member']['sub'][2]['caption']='SOSO';
$config['menu']['member']['sub'][2]['url']='http://www.soso.com';
让它循环成这样
搜索(主菜单)
百度(子菜单)
------解决方案--------------------
Array
(
[menu] => Array
(
[member] => Array
(
[coption] => 搜索
[sub] => Array
(
[0] => Array
(
[caption] => 百度
[url] => http://www.baidu.com
)
[1] => Array
(
[caption] => 谷歌
[url] => http://www.google.com
)
[2] => Array
(
[caption] => SOSO
[url] => http://www.soso.com
)
)
)
)
)这样看不就清楚了吗
smarty
(主菜单)
(子菜单)
------解决方案--------------------
$config['menu']['member']['coption'] = '搜索'; $config['menu']['member']['sub'][0]['caption']='百度'; $config['menu']['member']['sub'][0]['url']='http://www.baidu.com'; $config['menu']['member']['sub'][1]['caption']='谷歌'; $config['menu']['member']['sub'][1]['url']='http://www.google.com'; $config['menu']['member']['sub'][2]['caption']='SOSO'; $config['menu']['member']['sub'][2]['url']='http://www.soso.com'; $ar = $config['menu']['member']; echo $ar['coption'], '<br>'; foreach($ar['sub'] as $v) echo "<a href="%24v%5Burl%5D">$v[caption]</a><br>"; <br><font color="#e78608">------解决方案--------------------</font><br>多少充都好。分析后,使用foreach就可以。 <br><font color="#e78608">------解决方案--------------------</font><br>顶帖收藏~~<br><br> <br><font color="#e78608">------解决方案--------------------</font><br>