I like to consider myself a skilled PHP dev, and this is definitely the first time I've had to ask this sort of question.
I'm having an issue with some code that I wrote. There isn't a much better way to describe it than to share exactly what it's doing and what it's supposed to do.
Not looking to pay, as this is probably a stupid 1 line fix that I'm just too sleep deprived to see.
The array the code reads from:
Code:
Result:
As you can see, it loops through the array for the categories fine, but the nested foreach loop that loops through the forums only loops once. Obviously, it is supposed to loop twice (once per category).
You can see the live results at http://www.nocss.ml/forum
I'm having an issue with some code that I wrote. There isn't a much better way to describe it than to share exactly what it's doing and what it's supposed to do.
Not looking to pay, as this is probably a stupid 1 line fix that I'm just too sleep deprived to see.
The array the code reads from:
PHP:
$forum = array(
"1" => array(
"name" => "Example Category",
"desc" => "This is an example category",
"forums" => array(
"1" => array(
"name" => "Example Forum",
"desc" => "This is an example forum",
"perm" => "all"
),
"2" => array(
"name" => "Example Protected Forum",
"desc" => "This forum can be written on by admin only",
"perm" => "admin"
)
)
),
"2" => array(
"name" => "Example Category",
"desc" => "This is an example category",
"forums" => array(
"1" => array(
"name" => "Example Forum",
"desc" => "This is an example forum",
"perm" => "all"
),
"2" => array(
"name" => "Example Protected Forum",
"desc" => "This forum can be written on by admin only",
"perm" => "admin"
)
)
)
);
Code:
PHP:
foreach($forum as $catkey => $cat)
{
$name = $cat["name"];
$desc = $cat["desc"];
$forums = $forum[$catkey]["forums"];
echo "<B><A HREF='index.php?".$url_login."c=$catkey'>$name</A></B><BR>$desc<BR><BR><PRE>";
foreach($forums as $forumkey => $forum)
{
$name = $forum["name"];
$desc = $forum["desc"];
$perm = $fourm["perm"];
echo " <A HREF='index.php?".$url_login."c=$catkey&f=$forumkey'>$name</A> Perm: $perm<BR> $desc<BR> $smallhr";
}
echo "</PRE><BR>".$medhr;
}
Result:
As you can see, it loops through the array for the categories fine, but the nested foreach loop that loops through the forums only loops once. Obviously, it is supposed to loop twice (once per category).
You can see the live results at http://www.nocss.ml/forum
