View Single Post
Old 03-05-2004, 08:06 PM   #3 (permalink)
MrFlux
Fluxing wildly...
 
MrFlux's Avatar
 
Location: Auckland, New Zealand
Huzzah! Here is how you can sort your array if you have the date/filename in it... much simpler than i thought:

PHP Code:
<?php
// Example unsorted array
// I'll leave it up to you to figure out how to build this array
// Unless you can't in which case I'll give you a hand ;P
$thumbs = array(
    array(
'231','filename.jpg'),
    array(
'312','filename2.jpg'),
    array(
'123','filename3.jpg'));
// This will sort $thumbs by the first index of the second dimension...
sort($thumbs);
// Output the example
foreach($thumbs as $key => $value){
    echo 
'Name: '.$thumbs[$key][1].'<br>';
    echo 
'Num: '.$thumbs[$key][0].'<br><br>';
}
?>
Just give me a yell if you need help building your thumbs array...

Edit: oh, here's the output of that script:

Name: filename3.jpg
Num: 123

Name: filename.jpg
Num: 231

Name: filename2.jpg
Num: 312


To reverse this (i.e. output by LATEST date instead of earliest) just stick in $thumbs = reverse_array($thumbs) before your output code...
__________________
flux (n.)
Medicine. The discharge of large quantities of fluid material from the body, especially the discharge of watery feces from the intestines.

Last edited by MrFlux; 03-05-2004 at 08:11 PM..
MrFlux is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76