Quantcast
Channel: Iterate over all items and sub items in a PHP array - Stack Overflow
Browsing latest articles
Browse All 3 View Live

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 Article


Answer 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 Article


Iterate 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
Browsing latest articles
Browse All 3 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>