Riseykins Posted December 9, 2008 Share Posted December 9, 2008 What do I need to add to the following code to make it sort alphabetically? <?php /* Copyright 2007 S. Benjamin Your Membership grants you the right to use this script You may modify this script to suit your needs, but you can not resell this script You are not allowed to give this script away, or resell this script or any part of it. Unauthorized sale or redistribution of this script will result in account termination without refund, and possible legal actions! Contact info: info@creativeaftermath.com http://www.creativeaftermath.com */ //////Build Catergories////// $cats = array(); if ($handle = opendir("/home/burning/public_html/layouts/cat/")) { while (false !== ($file = readdir($handle))) { if(($file != ".")&&($file != "..")){ array_push($cats, $file); } } closedir($handle); } ////End Build Catergories//// /////Build Nav///// $cat_count=1; foreach($cats as $cat){ $cat_strip = trim(preg_replace('/[^a-zA-Z]/', ' ', $cat)); echo '<a href="http://burningviolet.com/layouts/'.$site_url.'index.php?id='.$cat.'&page=1" title="'.$cat.' MySpace Layouts">'.ucfirst($cat_strip).' Layouts</a>'."\n";} /////End Build///// ?> Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/136220-solved-alphabetical-sorting/ Share on other sites More sharing options...
Maq Posted December 9, 2008 Share Posted December 9, 2008 sort Quote Link to comment https://forums.phpfreaks.com/topic/136220-solved-alphabetical-sorting/#findComment-710562 Share on other sites More sharing options...
premiso Posted December 9, 2008 Share Posted December 9, 2008 sort($cats); foreach($cats as $cat){ $cat_strip = trim(preg_replace('/[^a-zA-Z]/', ' ', $cat)); echo '<a href="http://burningviolet.com/layouts/'.$site_url.'index.php?id='.$cat.'&page=1" title="'.$cat.' MySpace Layouts">'.ucfirst($cat_strip).' Layouts</a>'."\n";} sort Quote Link to comment https://forums.phpfreaks.com/topic/136220-solved-alphabetical-sorting/#findComment-710569 Share on other sites More sharing options...
Riseykins Posted December 9, 2008 Author Share Posted December 9, 2008 Awesome! Thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/136220-solved-alphabetical-sorting/#findComment-710581 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.