arrays
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
arrays
ok this is really stupid but im sorry i cant figure it out or find it on google. im trying to open a directory then make a array out of the files in the directory then sort them into alphabetical order. i used readdir, then array (and tried file), then sort, then print the sorted array but the only result i could get was the number 1. help?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
lol sorry saviours of mine,
but i want the files to be displayed in alphabetical order. hook a brotha up 
Code: Select all
<?php
$dir = "users/" . $_SESSION['encrypt'] . "/diskdriver/beta";//point to the directory of the user
$opendir = opendir($dir);//open the dir
print "<a href='users/" . $_SESSION['encrypt'] . "/diskdriver.swf' target='_blank'>Play My Music!</a><br><br>";
while (false !== ($readdir = readdir($opendir))){
if ($readdir != "." && $readdir != ".."){
$readdir = str_replace(".mp3", "", $readdir);
print "$readdir";//print out the names of each file in the directory
}
}
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
$foo = array();Code: Select all
$fooї] = $readdir;Code: Select all
sort($foo);
print_r($foo);