tsilenzio Posted July 30, 2007 Share Posted July 30, 2007 Is it possible to nest a foreach loop inside another? If so is this done properly then: //<?php // -- Enable Text Highlighting for The Forum -- // $links = array( "Account" => array( "Home" => "index.php", "Login" => "login.php", "Action" => "action.php", "Logout" => "logout.php" ), "Control Panel" => array( "Create" => "create.php", "Delete" => "delete.php", "Ban" => "ban.php", "Unban" => "ban.php?step=unban" ) ); foreach($links as $key => $title) { echo("<p>\n<strong>$title</strong>"); foreach($title as $key2 => $val) { echo("<a href=\"$val\">$key2</a><br />"); } echo("</p>"); } Or somthign similar to that.. if i wrote that right, i didnt test it just wrote it into the textarea on this forum.. Thanks for your help! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 30, 2007 Share Posted July 30, 2007 looks okay test it out Quote Link to comment Share on other sites More sharing options...
Nakor Posted July 30, 2007 Share Posted July 30, 2007 Yep that'll work =) Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 30, 2007 Share Posted July 30, 2007 dat's ryt...dat'll work.. Quote Link to comment Share on other sites More sharing options...
btherl Posted July 30, 2007 Share Posted July 30, 2007 It's fine, except that you should be using $key instead of $title in your first echo. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.