↧
Answer by Rob for Iterate over all items and sub items in a PHP array
You probably want a recursive solution, not an iterative one. function build_navMap(&$navMap,$link) { foreach ($navMap as $l => &$nm) { $nm['link'] = "$link/$l.php"; if (isset...
View ArticleAnswer by Rob for Iterate over all items and sub items in a PHP array
You could use a foreach loop and string interpolation: foreach ($navMap as $a => &$nm) { $nm['link'] = "/pages/$a.php"; if (isset ($nm['subNav'])) { foreach ($nm['subNav'] as $b => &$sn)...
View ArticleIterate over all items and sub items in a PHP array
I have a huge PHP array which holds the navigation structure of the site. It basically looks like this: $navMap = array( array( 'title' => 'Home', ), array( 'title' => 'about us', 'subNav' =>...
View Article