Reply to RE: [PHP] Sorting Objects in an array by object properties

Your name:

Reply:


Posted by "Jared Williams" on 05/28/05 20:54

> Hello list,
>
> I have an array which holds some objects. Each object
> represent elements from an email header in a given mailbox.
> Each object has properties like "from", "sendtime", "subject" etc.
>
> I want to sort the order of the objects in the array by their
> attribute "sendtime" in order to get a list of email header
> sorted by their arrival time.
>
> Has anyone an idea how to solve this? I tried various of the
> array sorting functions but without success.
>

http://php.net/usort

function compare($h1, $h2)
{
return strcmp($h1->sendtime, $h2->sendtime);
}
usort($array, 'compare');

Jared

[Back to original 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

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