Re: Appending into associative arrays
| From: | Robert Cummings | Date: | Sun, 15 Apr 2007 19:40:06 +0000 |
| Subject: | Re: Appending into associative arrays | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252978@lists.php.net to get a copy of this message | ||
On Sun, 2007-04-15 at 20:36 +0100, Alister Bulman wrote:
> On 15/04/07, Zoltán Németh <znemeth@alterationx.hu> wrote:
> > 2007. 04. 15, vasárnap keltezéssel 21.20-kor Otto Wyss ezt írta:
> > > I want to sort directories according there modification time and thought
> > > accociative arrays would be perfect. But when I add an element like
> > >
> > > $dirs = array (filemtime($d) => $d)
> > (sorry the previous one is incorrect, I misunderstood what you
> > wanted...)
> > so:
> > $dirs[filemtime($d)] = $d;
>
> Better, I think, to put the unique thing - the name, as the index.
> Two directories may have the same modification time.
>
> $dirs[$d] = filemtime($d);
Has he even retrieved the directories in sorted order by modification
time? If not he still needs to sort.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'