bloodgoat Posted May 5, 2009 Share Posted May 5, 2009 Is it at all possible this way? <?php $a_navi = array(); $a_navi["IP Bans"] = array("Add", "bans&do=add", "Add a new IP to the current ban list"); $a_navi["IP Bans"] = array("View", "bans&do=view", "View the current ban list"); $a_navi["IP Bans"] = array("Clear", "bans&do=clear", "Clear the current IP ban list"); $a_navi[] = array("Configure", "config", "Modify your over-ride username, associated IP address, administrative panel password, date- and time-stamp formats, and paths to key files"); $a_navi["IP Log"] = array("View", "ip_log&do=view", "View the log of IP addresses associated with invalid administrative login attempts"); $a_navi["IP Log"] = array("Clear", "ip_log&do=clear", "Clear the log of IP addresses associated with invalid administrative login attempts"); $a_navi[] = array("Clear Global Chat", "chat&do=clear", "Clear the global chat log"); sort($a_navi); ?> Or would I have to do it the other way? <?php $a_navi = array( "IP Log" => array( array("View", "ip_log&do=view", "etc etc"), array("Clear", "ip_log&do=clear", "etc etc"), ), "IP Bans" => array( array("Clear", "ip_bans&do=clear", "etc etc"), array("View", "ip_bans&do=view", "etc etc"), array("Add", "ip_bans&do=add", "etc etc") ) ); ?> And even doing it the second way, I keep getting integers instead of the actual value (IP Bans, IP Log, etc). Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 They're all valid, but the first one is kind of stupid because you're overwriting the $a_navi["IP Bans"] array and the $a_navi["IP Log"] multiple times. I think you want the latter one. Quote Link to comment Share on other sites More sharing options...
bloodgoat Posted May 5, 2009 Author Share Posted May 5, 2009 I wasn't even confident if the first way was a proper method until I tried it. All my values seemed to be returned fine. I was mostly just being lazy. Regardless, even trying the second way, I'm still getting numeric value returns, which I don't want. I'm trying to use the keys as classification headers for the navigation, and "0", "1", and "2" are terrible classifications at best. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Do you mean the numeric reference in the array inside the $a_navi["IP Log"] and $a_navi["IP Bans"]? Quote Link to comment Share on other sites More sharing options...
bloodgoat Posted May 5, 2009 Author Share Posted May 5, 2009 Pretty much. This code: <?php $a_navi = array( "General" => array( array("Configure", "config", "Modify your over-ride username, associated IP address, administrative panel password, date- and time-stamp formats, and paths to key files"), array("Clear Global Chat", "chat&do=clear", "Clear the global chat log") ), "IP Log" => array( array("View", "ip_log&do=view", "View the log of IP addresses associated with invalid administrative login attempts"), array("Clear", "ip_log&do=clear", "Clear the log of IP addresses associated with invalid administrative login attempts"), ), "IP Bans" => array( array("Clear", "ip_bans&do=clear", "Clear the current IP ban list"), array("View", "ip_bans&do=view", "View the current ban list"), array("Add", "ip_bans&do=add", "Add a new IP to the current ban list") ) ); sort($a_navi); foreach($a_navi as $a_key => $a_linkk){ $a_links .= $a_key; foreach($a_linkk as $a_link){ $a_links .= "<a href=\"?action=admin&est=".$a_link[1]."\">".$a_link[0]."</a> | "; } } $a_links = substr($a_links, 0, -3); ?> Outputs like this: 0Configure | Clear Global Chat | 1View | Clear | 2Clear | View | Add When I want it to output with the actual key name instead of it's numeric value, like this: General Configure | Clear Global Chat | IP Logs View | Clear | IP Bans Clear | View | Add Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 It would be better if you put 'Configure' as a key instead of being in an array. So like: 'General' => array( 'Configure' => array('config', '...'); ); Then I guess you can just grab the keys. Quote Link to comment Share on other sites More sharing options...
bloodgoat Posted May 5, 2009 Author Share Posted May 5, 2009 Wouldn't this end up requiring an unnecessary amount of loops? And if I had enough configure options for it to be recognized as it's own category, I would, but as it stands, "config" is it's just own file with only a few variables that are going to be readily edited. Aside from that, would it at all fix my problem? Or would I still be getting numeric value displays? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Well your desired output is a bit tricky because you want the General to be combined with the first key, but not any of the keys after it. So you want General Configure but not General Clear Global Chat even though Clear Global Chat is in General. I would probably use two loops. It's not like your original setup is any easier. At least I don't think so. Quote Link to comment Share on other sites More sharing options...
bloodgoat Posted May 5, 2009 Author Share Posted May 5, 2009 OHH, I think you're misconstruing how I want the output to be displayed. Here, I'll throw in some line breaks a little more symbol-work so you see how I want the output. Current: 0: Configure | Clear Global Chat 1: View | Clear 2: Clear | View | Add Log out Desired: General: Configure | Clear Global Chat IP Log: View | Clear IP Bans: Clear | View | Add Log out Like, each key is a header for it's own navigational segment, and the "|" separates each link in that segment. So both "Clear Global Chat" and "Configure" are under the "General" header. But disregarding all of this... I still can't get the keys to display themselves as themselves, not their numeric association. AHHHH Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 I like my setup more. foreach ($a_navi as $key => $value) { $value_keys = array_keys($value); echo $key . ': ' . implode(' | ', $value_keys); } Quote Link to comment Share on other sites More sharing options...
bloodgoat Posted May 5, 2009 Author Share Posted May 5, 2009 I keep getting numeric output from that. And I didn't even know about the array_keys() function, oh boy. I tried using that on the main page of the admin panel as sort of a test, with this code: <?php $title = "Main Panel"; $content .= "\n<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"900\" align=\"center\">"; foreach($a_navi as $a_key => $a_panel){ $a_key = array_keys($a_navi); $content .= "\n <tr>". "\n <td colspan=\"2\" class=\"f_head\">".$a_key."</td>". "\n </tr>"; foreach($a_panel as $a_pan){ $content .= "\n <tr>". "\n <td width=\"20%\" class=\"apleft\"><a href=\"?action=admin&est=".$a_pan[1]."\">".$a_pan[0]."</a></td>". "\n <td width=\"80%\" class=\"apright\">".$a_pan[2]."</td>". "\n </tr>"; } } $content .= "\n <tr>". "\n <td class=\"apfoot\" colspan=\"2\"> </td>". "\n </tr>". "\n</table>"; ?> And it just output this: http://i204.photobucket.com/albums/bb303/img0t/Untitled-2.png The horizontal navigation towards the top shows how it is pre-array_keys() and the actual table is post-array_keys(). Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 You shouldn't get the numbers if you used my format. Quote Link to comment Share on other sites More sharing options...
bloodgoat Posted May 5, 2009 Author Share Posted May 5, 2009 <?php foreach ($a_navi as $key => $value) { $value_keys = array_keys($value); echo $key . ': ' . implode(' | ', $value_keys); } ?> Literal copy and paste, this was the output: 0: General1: IP Log2: IP Bans I figured it out anyways. I had to put each key into it's own array, and then create an array for that key afterwards. Basically just changed this: <?php $a_navi = array( "General" => array( array("Configure", "config", "Modify your over-ride username, associated IP address, administrative panel password, date- and time-stamp formats, and paths to key files"), array("Clear Global Chat", "chat&do=clear", "Clear the global chat log") ) // as well as my other arrays, just using one for the example ); ?> To this: <?php $a_navi = array( array("General" => array( array("Configure", "config", "Modify your over-ride username, associated IP address, administrative panel password, date- and time-stamp formats, and paths to key files"), array("Clear Global Chat", "chat&do=clear", "Clear the global chat log") )) ); ?> And added a third loop. It displays just how I wanted it to, now. Quote Link to comment Share on other sites More sharing options...
Fire768 Posted May 18, 2009 Share Posted May 18, 2009 I think I might use those codes for my problems.,It might help me., _________________ IP PBX 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.