sorting - PHP scandir results: sort by folder-file, then alphabetically -


php manual scandir: by default, sorted order alphabetical in ascending order.

i'm building file browser (in windows), want addresses returned sorted folder/file, alphabetically in subsets.

example: right now, scan , output

aardvark.txt bardir bazdir dante.pdf foodir 

and want

bardir bazdir foodir aardvark.txt dante.pdf 

other usort , is_dir() solution (which can figure out myself), there quick , efficient way this?

the ninja wrote this comment on right track - best way?

does give want?

function readdir($path) {      // make sure have trailing slash , asterix     $path = rtrim($path, '/') . '/*';      $dirs = glob($path, glob_onlydir);      $files = glob($path);      return array_unique(array_merge($dirs, $files));  }  $path = '/path/to/dir/';  readdir($path); 

note can't glob('*.*') files because picks folders named like.this.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -