Jump to content

[SOLVED] loop directory in alphabetical order


andy182

Recommended Posts

I have made the following code to list the files in a directory, but wondering if there's any chance you could help me and explain how to list them in alphabetical order.

 

<?php
$path = "tabs/";
$dir = opendir($path);
echo "<ul>\n";

while($file = readdir($dir))
{
if ($file != "." && $file != ".." && $file != ".php")
{
list ($name, $ext) = explode (".", $file); 
echo "<li><a href = \"" .$path.$file. "\" target = \" _blank\"> ".$name." </a></li> \n";
}
}
echo "</ul>\n";
closedir($dir)
?>

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.