I use this code to list all files in directory:
$d = dir($FolderToPlay); while (($file = $d->read()) !== false){ ... ... } $d->close();
But, the result is not in the numerical order. How can I fix it?
Advertisement
Answer
Get a list of all the filenames, then you can use a sorting function.
$d = glob("$FolderToPlay/*"); natsort($d); foreach ($d as $file) { ... }