<?function order_email($a, $b){ // is $a and $b an id from the array? or what is it? global $imap; $timea = imap_headerinfo($imap, $a); $a = $time->udate; // get the time the email was sent in unixtime $timeb = imap_headerinfo($imap, $b); $b = $time->udate; // get the time the email was sent in unixtime if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; }}$mails = imap_search($imap, "UNDELETED"); // Gets array with id's of mailsusort($mails, "order_email"); // The array of mails should be ordered by the time they were recieved?>