关于数组循环的一个有关问题
关于数组循环的一个问题
$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
(主菜单)
(子菜单)
------解决方案--------------------
- PHP code
$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>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



While installing a new version of an application, Windows may display this error message "An error occurred while parsing C:\\Windows\Microsoft.Net\Framework\v2.0.50727\Config\machine.configParser returned error 0xC00CE556". This problem also occurs when your system boots. No matter what situation you encounter this problem, .NETFramework is the real culprit behind the scenes. There are some very simple fixes you can use to stop this error code from appearing again. Fix 1 – Replace corrupted files You can easily replace corrupted ma from the original directory

With the continuous development of the PHP language, ThinkPHP, which is widely used in the PHP back-end framework, is also constantly improving. As business scenarios become increasingly complex, the demand for configuration management in ThinkPHP is also increasing. In this context, ThinkPHP provides rich configuration management functions. Today we will introduce how to implement configuration management through ThinkPHPConfig. 1. Introduction to ThinkPHPConfig ThinkPHPConfig is Thin

1. Introduction to CodeIgniter CodeIgniter is a lightweight and comprehensive PHP development framework designed to provide web developers with fast and powerful tools to build web applications. It is an open source framework that uses the MVC architecture pattern to achieve rapid development and basic functions, while supporting a variety of databases. 2. Introduction to the Config library The Config library is a component in the CodeIgniter framework and is used to configure and manage code. The Config library contains many

For macOS users, some commonly used software may be directly accessible through the Menubar in the upper right corner. However, as time goes by, you will find that there are more and more icons and your Menubar will gradually become longer and longer. If you use a MacBook, it is more likely to go beyond the middle position of the "bangs". This time I recommend a set of free and open source macOS tools called HiddenBar. Its biggest function is to allow you to shorten the Menubar and hide things that are not commonly used. Separated display area After installing this app, a separated area map will appear. Things on the left side of this mark will be hidden, and only things on the right side will be visible. Usage method 1: Set the partition first, and then move the less frequently used apps to the left of the partition. 2

Laravel is a popular PHP framework that provides many convenient features to developers. One of the most useful features are configuration files, which can be used to store settings and options within an application. In this article, we will explain how to configure an application using LaravelConfig. What is a configuration file? Within the application, there are many settings to set up and manage. These settings include database information, third-party API keys, and application behavior. In some cases, these settings may need to be

Sonos just launched its most affordable soundbar yet, the Ray. The product launched as the company's next product will be a good companion to the compact Ray and Beam soundbars. Last month, we got a detailed look at the Sonos SubMini thanks to renders created by TheVerge after seeing leaked images of the product. Now, Sonos FCC documents (via The Verge) reveal the underside of the Sonos Sub Mini and confirm that the expected design is accurate. The FCC image also points to a black and white variant, which is intended to match the options on the Ray and Beam soundbars (as well as other Sonos products)

Phalcon is a PHP framework that provides powerful and efficient tools to build web applications, one of which is PhalconConfig. PhalconConfig provides a flexible way to manage configuration information in applications. In this article, we will introduce the basic concepts of PhalconConfig and how to use it for configuration management in PHP applications. 1. What is PhalconConfig? PhalconConfig is a

Solution to vue menu not refreshing: 1. Write "<router-view v-if="!$route.meta.keepAlive"></router-view>" on the index page; 2. Set the cache name to "test -keep-alive"; 3. Configure "{path: '/Material',name: 'Material'...}" in the router file.
