Creating a site using Codeigniter. I have used codeigniters directory helper to get the filenames of all files in a directory:
$this->load->helper('directory');
$files = directory_map('directory_name/', 1);
This all works as expected and I get a list of the files in the directory - print_r($files) proves this.
However, the file names all start with numerical values:
1_firstfile.doc
2_nextfile.doc
3_another.exe
... ...
11_thisfile.txt
12_filename.pdf
My problem is that the files are returned in a different order that I would like. I wish them to be returned in the order above, but instead they are returned like this:
1_firstfile.doc
11_thisfile.txt
12_filename.pdf
2_nextfile.doc
3_another.exe
Obviously, they are being returned in alphabetical order, but I need them returned in numerical order.
I have tried $files = sort($files,1) but that seems to just empty the array.
So, apart from changing the filename, how can I get the array to arrange them in the order I require?