I've just recently started learning php and its going rather well. I have created a script that goes through the files in a folder and looks for files matching a few conditions. It then creates list items in a menu. It works perfectly for my main navigation. But when I call it to create a secondary menu it returns an empty array instead of the file names as it is supposed to. Variables and includes
The first call to nav() generates three filenames as I expect it to. The second call returns empty though I have double and tripple checked that I have two files that should match.
Feel free to suggest other changes that could be made to reduce the ammount of code or if there are better, safer, ways to write any of this. I know its alot of code but I would be very greatfull.
$filename is just a boolean, so unset($filename) doesn't do what you think it does. You need to use closedir() to reset your readdir() function, which means you need to rethink when you use opendir().
Okay, that will put me on the right track. I was thinking about rewriting the entire thing anyway because it started out as 4 line function and I've just put stuff in and try to make it work.
Variables and includes
Here are the two functions that do the heavy liftingAnd the part that calls for the nav() function:
Thank you so much.