Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Array Question (Sorting) - Same but different

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Array Question (Sorting) - Same but different

Postby Xer0 » Mon Jan 06, 2003 9:34 pm

I have a problem similar to this.

I have to gather extra information on the file. My array structure is like this:

$files[$file]['date]
$files[$file]['description']

I need to reverse sort by date. I have had a look at array_multisort but am not sure that this is what I need.

- Xer0
Xer0
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Jan 06, 2003 9:27 pm

Postby jasonthomasfrance » Mon Jan 06, 2003 11:16 pm

Howdy,

Something like this won't work for you:

arsort($images,SORT_NUMERIC);

That line sorts my array by date (newest to oldest). I would suppose you'd have to get the file info with: if(is_file($file))$images[$file]=filemtime($file);

Does that sound right?
jasonthomasfrance
New php-forum User
New php-forum User
 
Posts: 6
Joined: Fri Jan 03, 2003 3:07 am

Postby Xer0 » Wed Jan 08, 2003 2:12 am

This would work except I also need to store a description of each file, like so:

$images[$file]['date'] = filemtime($file);
$images[$file]['description'] = GetDesc($file);

GetDesc is a function I wrote :)

arsort doesn't work properly, probably because $images[$file] is another array, not a value (eg date)

- Xer0
Xer0
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Jan 06, 2003 9:27 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron