• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sorting filenames from directory


I'm getting the filenames from a directory to an array and I want to sort the filenames inside that array. The problem is, if you use sort($filenames) this will result in a sort like this: "img 1.jpg", "img 10.jpg". "img 11.jpg",... etc. He puts page 2, 3, ..., 9 in the end.

I'm not sure why he's doing this but it seems that it's somehow related to the fact that this numbers are not integers but, instead, they're strings... They're not organized by their value but by their char code... I don't know. What I know is that I should have finished this project last weak and I'm still &$%#?# with it :S

Anyone have a function that sorts this array properly?

help? Please?


btw, renaming the files isn't an option...

the natsort() function in PHP might help.

Thank you so much!
Problem solved!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.