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

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.