[RESOLVED] Sorting array problem
I have populated an array first column with filenames and second column with folder and filenames. I want to sort the array with respect to filename i.e. first column. I tried different array sorting functions but none gave me correct results.
Here's my code.
Code:
while (($file = readdir($dh)) != false) {
// print "filename: $file : filetype: " . filetype($dir . $file) . "\n";
if(filetype($dir . $file)!='dir' and !in_array($file,$att))
{
$filearray[$i][0] = $file;
$filearray[$i][1] = $dir.$file;
$i++;
}
}
Thanks.
Re: Sorting array problem
Have you looked atarray_multisort() might do just what you want. Check out the comments as well as there is loads of useful information that will help you, or could point you to a better solution.
Re: Sorting array problem
I don't know why but none of the sort functions were working. Finally, I wrote my own sort function using selection sort and its working now.
Thanks.