View Single Post

  #3 (permalink)  
Old 10-25-2006
Rik
 
Posts: n/a
Default Re: Ordering array won't work?

frizzle wrote:
> Hi there,
>
> I want to scan a dir, put the *.gif into an array, and order that (
> 01.gif, 02.gif etc),
> and put that array into a $_session-array. (Session & Headers are
> initiated before this code)
> I have the code below, everything works, except for the ordering.
>
> Any clues ?


> $_SESSION['all_pics'][$filename] = "Foobar";


> asort( $_SESSION['all_pics'] );


Well, if the value of every array item is the same, offcourse there will be
no sorting done.
If you want to sort on key:
ksort($_SESSION['all_pics']);

Allthough I can't image why:
$_SESSION['all_pics'][] = $filename;
...
asort($_SESSION['all_pics']);
does not do...
--
Rik Wasmus


Reply With Quote