I am an absolute beginner in PHP. I have a file main.php where I have a call to a php function:
<div id="navigation">
<nav>
<?php echo navigation('exclude'=>array('/about.php')) ?>
</nav>
</div>
I have a file navigation.php which is required in main.php, it has a small constructor to build the right structure of the navigation, it looks like this:
<ul class="navi naviTop">
<?php foreach($page as $key=>$singlepage){
if(!isset($singlepage['submenu'])){ ?>
<li class="navIem <?php echo $singlepage['name'];?>">
<a href="<?php echo $key; ?>">
<?php echo $singlepage['name'];?>
</a>
</li>
<?php } else { ?>
<ul class="hasSubs">
<?php foreach($singlepage['submenu'] as $subkey=>$subpage){ ?>
<li class="navItem subitem">
<a href="<?php echo $subkey; ?>">
<?php echo $subpage['name'];?>
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
</ul>
This works completely fine for me, but I want to have some options, that's why I establish a function:
function navigation($arguments=array()){
$defaults = array(
'class' => '',
'exclude'=> array()
);
$opts = array_merge($defaults, $arguments);
What is the right way for me to return this HTML structure that I generate by calling the navigation function?