Jump to content

Ordering Categories into alphabetical order


Schlo_50

Recommended Posts

Hey guys,

 

I have some categories ($catname) and need to order them alphabetically a-z. Any ideas? Anyone?

 

$imagename = trim($Data[$i][0]);
$catname = trim($Data[$i][1]);
if(strlen($catname) > 12){
  $catname = substr($catname, 0, 12);
  $catname = trim($catname);
  $catname = "$catname...";
} else {
  $catname = $catname;
}
$description = str_replace("[break]", "<br>", $Data[$i][2]);

$data = file("admin/data/threads.DAT");
$Lines = find_by_col($data, 3, $imagename);

$itemcount = count($Lines);

if(file_exists("$imgdir/$imagename.jpg")){
  $img = "$imgdir/$imagename.jpg";
} else {
  $img = "$noimgdir/comingsoon.jpg";
}

if (($i % 3) === 0 && $i > 0) {
  print "</tr><tr>\n";
}
print "<td><p align=\"center\"><a href=\"$link=$imagename\"><img src=\"$img\" border=\"0\"><br><b>$catname</b></a><br>$description</p></td>\n";

}

print "</tr>";
print "</table>";

 

Thanks

Link to comment
Share on other sites

i found this in a search, not sure it is what you want but you may be able to modify to do what you wish

<?php
if ($handle = opendir('.')) { // read the current directory. Change the "." to the directory you need.
$filecount = "0"; //reset the number of files
while (false !== ($file = readdir($handle))) { 
if ($file != "." && $file != "..") { // remove the move up directory commands. (. and ..)
$file = strtolower($file); // make all filenames lowercase (looks better. can be removed)
$fileList[] = trim($file); // add the file to an array so it can be sorted easily.
$filecount = $filecount + 1; //count the number of files
} 
}
print 'File Count: <b>'.$filecount.'</b><br>'; //display the number of files
sort ($fileList); // sort the file list in the array
reset ($fileList); // go back to the top of the array
while (list ($key, $val) = each ($fileList)) {
echo $val.'<br>'; //print the list.
}
closedir($handle); 
}
?>

[code]

[/code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.