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

From: Date: Sat, 28 May 2005 17:54:11 +0000
Subject: RE: [PHP] Sorting Objects in an array by object properties
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-215954@lists.php.net to get a copy of this message
> 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

« previous php.general (#215954) next »