Forum Moderators: coopster
I have a clever menuscript in php that i cant quite get to work. it is basically two functions, but i cant get the first to call the next function. the idea for this is to reuse the menu() with the different menuitems.
first function:
function menu() {
$namecount = count($name); for ($i = 0; $i < $namecount; $i++) { if ($url[$i] == $file)
{ echo ("<li><a class=\"now\" title=\"$title[$i]\">$name[$i]</a></li>"); }
else { echo ("<li><a href=\"$url[$i]\" title=\"$title[$i]\">$name[$i]</a></li>"); } }
print"</ul>\n";
and the main function
function hvem() {
echo "<h3>Hvem</h3><div id='sidenav'><ul>\n";$name = array ( "foo");
$url = array ( "/index.php");
$title = array ( "foo_title");
$file = $_SERVER['PHP_SELF'];
menu();}
What this does is to check whether the file being called is identical with the url and then higlighting it if this is the case.
But how to make the "menu()" get executed? i have tried many ways but nothing seems to work for this newbie. it doesnt throw a parse error. any suggestions? i hope i am not way off.
Thanx in advance
Hafnius
Thanks for the reply, Birdman
You may need to declare your variables as global.
i still just get the headline on the menu, not the menuitems in the array:
echo "<h3>Hvem</h3><div id='sidenav'><ul>\n";
i feel this shoul be pretty straight forward but i cant seem to cut it.
Should i post a dummy to play with?
Regards
Hafnius