Jump to content

Dump content into ARRAY and SORT


JREAM

Recommended Posts

If you look at the // COUNTER  thats where im counting the files,

Im trying to get all the files into an array, then print them (so i can sort, and do all kinds of stuff)

but i only get 1 file to list

 

#IGNORE ALL THIS
function list_all_mp3 () {
$directory = 'public/downloads/audio/';
$results = array();
$handler = opendir($directory);

# HERE THE COUNTER
$i = 0; // COUNTER
while ($file = readdir($handler)) {


if ($file != '.' && $file != '..') {

# HERE THE COUNTER
$i++; // COUNTER

$mp3 = $file;
$filesize = filesize($directory . $mp3);
$fh = fopen($directory . $mp3, "r");
fseek($fh, -128, SEEK_END);

$tag = fread($fh, 3);
if($tag == "TAG") {
	$title = trim(fread($fh, 30));
	$speaker = trim(fread($fh, 30));
}
else die("MP3 file does not have any ID3 tag");

fclose($fh);

# HERE THE ARRAY
$aud1 = array($i, "<a name='$mp3' href='$directory$mp3'><strong>$title</strong></a></li>\n");

/*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*/

}
}
closedir($handler);
var_dump($aud1);
}

Link to comment
https://forums.phpfreaks.com/topic/134741-dump-content-into-array-and-sort/
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.