need some help with a script to sort images for a gallery. I have the thumbnails in a dir and need to display them in the order that you would see them in windows. here is my code: 'gets all thubnails from the dir' $dirtoopen="artist/".$galName; $tn=0; if ($handle = opendir($dirtoopen)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $tn++; $tNF[$tn]=$file; } } closedir($handle); The order that they are retrieved in is not the same order that I view them in ftp or within windows. I have added sort($tNF); after the closedir($handle); but the orde3r still isn't right. With the sort it displayes numbers (070706a) then jumps to letters (Untitled-03-09-2007) then underscores (_63) and finally back to letters (a15 ) here is a list of how it is outputing the sorted array. 3d1, 3d2, 3d3small, 3d4, Untitled-111, Untitled-1a, Untitled-1b, Untitled-1f, Untitled-1nnn , Untitled-38-copya, Untitled-38, Untitled-4-copya-redo, Untitled-51, Untitled-52, Untitled-54, Untitled-55, art5a, art7, cs5, ff02, ff03, ff04, ff05, ff06, hane-1, k1, k2 Please help me figure out how to sort them (_,00-99,aA-zZ) This is what is currently outputing: Untitled-05, Untitled-1cs3a-better, Untitled-38, Untitled-41, _6A, art12-copy, cs4, fractal-apple, hane-1, objects And this is what it should be: _6A, art12-copy, cs4, fractal-apple, hane-1, objects, Untitled-1cs3a-better, Untitled-05, Untitled-38, Untitled-41,
natsort($tNF) outputs (broken link)-should be 'Untitled-05' Untitled-41 objects art12-copy fractal-apple Untitled-1cs3a-better cs4 hane-1 Untitled-38 _6A
does anyone know how to use the usort function? I think that might work but I have no idea how to create the user defined comparison.