Simon336697
asked on
PHP function not sorting from A-Z across the menu for the links in my pages
Hi guys hope u are well and can assist.
I have the following function which grabs a list of filenames and creates links out of them to build a menu system.
The problem I have as you can see in the screen dump is that the links are not being displayed alphabetically eg.A - Z from left to right.
For example, in row 2, "auditing" is seen way to the right when it should be where "hware" is.
If someone can help me with the below function, which I think is causing this, through not having a sorting facility, id very much appreciate it.
Thank you.
In my php pages, the function gets called as follows....
<div id="menu2_div">
<ul id="menu2_ul">
<?php echo menu2_navlinks($menu2_page s, $menu2_current_page); ?>
</ul>
</div>
I have the following function which grabs a list of filenames and creates links out of them to build a menu system.
The problem I have as you can see in the screen dump is that the links are not being displayed alphabetically eg.A - Z from left to right.
For example, in row 2, "auditing" is seen way to the right when it should be where "hware" is.
If someone can help me with the below function, which I think is causing this, through not having a sorting facility, id very much appreciate it.
Thank you.
In my php pages, the function gets called as follows....
<div id="menu2_div">
<ul id="menu2_ul">
<?php echo menu2_navlinks($menu2_page
</ul>
</div>
function menu2_navlinks($menu2_pages, $menu2_current_page){
foreach ($menu2_pages as $menu2_pagename=>$url) {
//$menu2_navlinks = '';
/* ............................................................
Test to see if the link's url is the same as the current
page variable against the current page.
If they're the same - set the class to current_link
..........................................................*/
if ($url==$menu2_current_page){
$menu2_class='menu2_current_link';
$menu2_style="<span class=\"$menu2_class\">";
$menu2_end_style='</span>';
}
else { //otherwise leave the class blank
$menu2_style='';
$menu2_end_style='';
}
/* ............................................................
As the loop runs, it will add each link based on whether or
not it's the current page
..........................................................*/
$menu2_navlinks.="<li>$menu2_style<a href=\"$url\">$menu2_pagename</a>$menu2_end_style | </li>\n";
}
return $menu2_navlinks;
// End the function ...
}
links-in-menu2-not-sorted-A-Z-le.bmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
asort works!!!!!
Thank you mate...champion as always.
S