You are here: Re: [PHP] GLOB sort order « PHP « IT news, forums, messages
Re: [PHP] GLOB sort order

Posted by Georgi Ivanov on 11/22/05 13:42

On Tuesday 22 November 2005 11:41, Mark Lucas wrote:
> Can anyone help me please? I'm not an advanced PHP user!
>
> I'm looing for a way to sort the array returned by the GLOB function. I
> would like to be able to sort the result by filemtime.
>
> Any good ideas?

I think you can walk the array returned by glob and create a hash :
$arr=glob(..);
foreach($arr as $file){
$stat=stat($file);
$mtime=$stat[mtime];
$new[$file]=$mtime;
}

Now you should have array like this :
foo.txt => 19879823
foo1.txt => 1987987998
Now you can use array_sort function to sort the new array.

Good luck.
>
> Thanks,
>
> Mark
>
>
> ___________________________________________________________________________
>__
>
>
>
> St John's Church, Polegate - Making Disciples of Jesus Christ
>
> ___________________________________________________________________________
>__
>
>
>
> This email is intended solely for the addressee and is strictly
> confidential.
>
> If you are not the addressee please delete the message from your computer.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация