You are here: Re: sorting an array.. need help « PHP Programming Language « IT news, forums, messages
Re: sorting an array.. need help

Posted by Sune Storgaard on 01/30/06 18:50

namemattersnot@msn.com wrote:
> i've have the following array:
>
> files['name'][1]
> ['size'][1]
> ['time'][1]
> files['name'][2]
> ['size'][2]
> ['mtime'][2]
> ..etc.
>
> how do I sort this array according to "time" index? so that, for
> example, files['name'][0] would give "my_file.txt" that was last
> created?

A little *dirty* trick is to rearrange the array into a new array, where the
time is first entry.
In this case, swap it around so you get
files
['time'][1]
['size'][1]
['name'][1]
When you sort it now, it will be correct as its sorted on first entry =
time.
Then swap it back to the original structure.

See the "smith / johnson/ berger" example at php.net/sort

 

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

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