php create navigation menu from multidimensional array dynamically(php从多维数组动态创建导航菜单)
问题描述
我对此进行了研究,但无法找到确切的答案.此处与此相关的大多数问题/答案似乎尚未完成.如果有人知道类似于我的问题的最终解决方案,请指出我的方向!
I did research on this, and wasn't able to find an exact answer. Most of the questions/answers on here pertaining to this seem to be unfinished. If anyone knows of a finished solution similar to my question, please point me in that direction!
这是我的数组:
我想把它变成这样:
数组将动态生成,但限制为 3 个级别,例如:about->about2->sub-sub-about.我尝试解决这个问题:PHP/MySQL Navigation Menu 但它们看起来并不真正得出结论?我熟悉 foreach 的 while 和 for 循环,但我似乎无法理解这个.
The array will be dynamically generated, but will have a limit of 3 levels ex: about->about2->sub-sub-about. I tried going off of this question: PHP/MySQL Navigation Menu but they didn't really seem to come to a conclusion? I am familiar with foreach's whiles and for loops but I just can't seem to wrap my head around this one.
Enzino,您的代码有效!
推荐答案
这是我的解决方案:
Here is my solution:
这篇关于php从多维数组动态创建导航菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!