Re: PHP: Mulitiple Arrary Sort
| From: | Jim Lucas | Date: | Wed, 03 Sep 2008 04:58:48 +0000 |
| Subject: | Re: PHP: Mulitiple Arrary Sort | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279372@lists.php.net to get a copy of this message | ||
Vernon wrote:
I've gotten the one array down and I've figured out how to sort that array, however, I need to sort the array by the modified date of the file. Here's what I got so far: <?php // Open current directory if($handle = opendir($dir)){ // Loop through all files while(false !== ($file = readdir($handle))){ // Ignore hidden files if(!preg_match("/^\./", $file)){ // Put dirs in $dirs[] and files in $files[] if(is_dir($file)){ $dirs[] = $file; }else{ $files[] = $file; } } } // Close directory closedir($handle); // if $files[] exists, sort it and print all elements in it. if(is_array($files)){ //HERE IS MY CURRENT SORT WHICH I KNOW I NEED TO CHANGE BUT AM UNSURE HOW sort($files); foreach($files as $file){ $completeFileName = $dir . $file; //I WANT TO SORT BY THIS echo date("m-d-Y", filemtime($completeFileName)) . "<br>"; } } } ?> Any ideas on how to fix this? ThanksWe need to see what is in the array, not just how you think you need to manipulate it. Show us the basic structure of the array, with a few examples of data that would represent what you would normally be building the table out of. Then, with that, we might be able to start helping you.