This question is more operationg system specific than php but the problem starts in php.
According to php.net in function readdir description: "The filenames are returned in the order in which they are stored by the filesystem".
Many people developed some code to sort these returned names and i think they are ok.
For specific problems on my code i cant use the solutions provied.
So, i am thinking on changing the order filenames are "sorted" on my linux server.
Any idea on how to view this order and edit it?
Thanx a lot.
readdir problem.
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: readdir problem.
You can't really change that. It's filesystem dependent. Not exactly something you can modify without root acess... and even then, probably without changing the kernel/fs source.frederix wrote:This question is more operationg system specific than php but the problem starts in php.
According to php.net in function readdir description: "The filenames are returned in the order in which they are stored by the filesystem".
Many people developed some code to sort these returned names and i think they are ok.
For specific problems on my code i cant use the solutions provied.
So, i am thinking on changing the order filenames are "sorted" on my linux server.
Any idea on how to view this order and edit it?
Thanx a lot.
If the scripts available don't do what you need you can always write your own. the basic concept would be to get all filenames into an array and there's a whole host of array functions to help you from there on ...
Thanx for the reply.
I have folder with 4 subfloders names "1", "2", "3", "4".
When i call them with readdir the output order is not 1,2,3,4.
The order in my example on is "3,1,2,4".
I need an order for this output(1,2,3,4) and i want to change in the server and not in the code if possible.
Maybe there are "commands" to change the storage information of files.
readdir uses this storage information for output order.
Thanx again and i hope this clear things.
I have folder with 4 subfloders names "1", "2", "3", "4".
When i call them with readdir the output order is not 1,2,3,4.
The order in my example on is "3,1,2,4".
I need an order for this output(1,2,3,4) and i want to change in the server and not in the code if possible.
Maybe there are "commands" to change the storage information of files.
readdir uses this storage information for output order.
Thanx again and i hope this clear things.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
There are no commands you as a "user" can run to change the filesystem. I've never known any modern filesystem to do that though... the only time I see that bevahiour is with numbers without leading zeros.frederix wrote:Thanx for the reply.
I have folder with 4 subfloders names "1", "2", "3", "4".
When i call them with readdir the output order is not 1,2,3,4.
The order in my example on is "3,1,2,4".
I need an order for this output(1,2,3,4) and i want to change in the server and not in the code if possible.
Maybe there are "commands" to change the storage information of files.
readdir uses this storage information for output order.
Thanx again and i hope this clear things.
Either way, a simple sort() would do that for you