note 116727 added to function.imap-fetch-overview
| From: | Nitrogen | Date: | Fri, 20 Feb 2015 01:18:48 +0000 |
| Subject: | note 116727 added to function.imap-fetch-overview | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201762@lists.php.net to get a copy of this message | ||
Judging from the comments here, it appears like people are forgetting the basics to
already-available PHP sorting functions. Use usort(); and the tiniest custom function ever to
compare them all.
Change the arguments to imap_fetch_overview to your own, obviously.
<?php
$result = imap_fetch_overview($imap_stream, '1:10', 0);
usort($result, function($a, $b) {
return($b->udate-$a->udate);
});
?>
This usort function will look at each overview and order them in the exact latest to oldest message
order as determined by the "udate" value for each message. This works. I'm using it.
They're sorted in the exact order they appear in my actual inbox. Why obfuscate it any more?
----
Server IP: 72.52.91.14
Probable Submitter: 82.4.251.69
----
Manual Page -- http://php.net/manual/en/function.imap-fetch-overview.php
Edit -- https://master.php.net/note/edit/116727
Del: integrated -- https://master.php.net/note/delete/116727/integrated
Del: useless -- https://master.php.net/note/delete/116727/useless
Del: bad code -- https://master.php.net/note/delete/116727/bad+code
Del: spam -- https://master.php.net/note/delete/116727/spam
Del: non-english -- https://master.php.net/note/delete/116727/non-english
Del: in docs -- https://master.php.net/note/delete/116727/in+docs
Del: other reasons-- https://master.php.net/note/delete/116727
Reject -- https://master.php.net/note/reject/116727
Search -- https://master.php.net/manage/user-notes.php