Jump to content

Sort file names / sort array?


Stavros

Recommended Posts

Hi all I have been trying to sort this one out for hours now. I just need to sort my list alphabetically, any advise appreciated.

 

This what I have so far

 

if ($handle = opendir('./Items/')) {

  while (false !== ($file = readdir($handle)))

  {

  if ($file != "." && $file != "..")

  {

$thelist .= '<a class ="preview" href=Items/'.$file.'>'.$file.'</a> <br>';

  }

  }

  closedir($handle);

  }

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  

$Pics = array ($thelist);

sort($Pics);

foreach ($Pics as $key => $val)

{echo "Pics[" . $key . "] = " . $val . "\n";}

Link to comment
https://forums.phpfreaks.com/topic/234314-sort-file-names-sort-array/
Share on other sites

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.