How can I re-arrange a array of objects like this:
[495] => stdClass Object
(
[date] => 2009-10-31 18:24:09
...
)
[
Since the original question is about sorting arrays of stdClass() objects, here's the code which would work if $a and $b are objects:
usort($array, function($a, $b) {
return strtotime($a->date) - strtotime($b->date);
});
Or if you don't have PHP 5.3:
function cb($a, $b) {
return strtotime($a->date) - strtotime($b->date);
}
usort($array, 'cb');