Needed Navigation Html
- About
- Services
- Products
- Contact
- FAQs
- Sitemap
- Privacy Policy
- Column Layouts
- 1 Column
- 2 Column (Left Sidebar)
- 2 Column (Right Sidebar)
- 3 Column
- 4 Column
I want to use php arrays and foreach loops to output the needed html. The php code I have thus far is:
<?php
$data = array("navigation");
$data['navigation']['Home'] = base_url();
$data['navigation']['Pages'] = base_url('pages');
$data['navigation']['Pages']['About'] = base_url('pages/about');
echo '<ul>';
foreach($data as $nav) {
foreach($nav as $subNavKey => $subNavHref) {
echo "<li><a href='$subNavHref'>$subNavKey</a>";
}
}
echo '</ul>';
?>
I was thinking I would need three foreach loops nested but php warnings/errors are generated when the third loop is reached on lines such as:
$data['navigation']['Home'] = base_url();
$data['navigation']['Pages'] = base_url('pages');
I'm not quite sure how to test for 3rd level depths such as:
$data['navigation']['Pages']['About'] = base_url('pages/about');
Also, outputting the needed li and ul tags in the proper positions has given me trouble aswell.

array("navigation");Creates an array with one element, the string"navigation". I think you want$data = array("navigation" => array());