PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
what it does you all probably know, it just displays the files that are in the path above on the web page.... but what i need it to do is just the same but in alphabetical order, can someone help me ?
yes i did i replaced it , but i think im doing something wrong, i dont no php that well i tried to implement it but it didnt work, can you point me in the right direction on what i need to put in my code from that to make it work?
Why don't you put the filenames in a array instead of attaching them to a string, then use array_sort() on them. Then you can loop through them when it comes to outputting them?
$files = array();
$dir = opendir($path);
$i=0;
while($file = readdir($dir)) {
if(($file != ".") && ($file != "..")) {
$files[$i]=$file;
$i++;
}
}
$files=sort($files,SORT_STRING);
$b=sizeof($files);
for($i=0;$i<$b;$i++)
echo $files[$i]; //Adjust to do what you want. At the moment it will print out the filenames in order.