hey folks,
i m building a menu which has unordered list inside unordered and it goes on. i can comprehend making a for each array for just unordered and listed items but how do i carry nested ul inside ul? i m new at php so its hard for me to imagine how to make it. can i get some help. e.g
The example logic_earth gave is called a recursive function, which basically is coded in such a way that it can call itself and not get caught in an infinite loop, it’s an elegant (usually) solution to any problem where you’re dealing with n tier hierarchy.
As far as nesting foreach loops, it’s basically like this.
Note the $val is reused in the inner foreach, because this is an array that holds the sub array.
You can go on forever, however for anything deeper than 2, the code is going to look too ugly and you should consider a function (pref. a recursive one).
looping i m just not very hands on with,
echoing is something easy
array is easy too
recursion is a new thing for me
still i fail to understand how is nested ul is assigned a different class than the outer ul. my concepts for php is very week as still i m a very new at this