This function will not return a full subject line if it is longer than 25 characters. I found this out after trying to search each header and move the email to a different folder depending on what the subject was (searching for year and project number).
(PHP 4, PHP 5)
imap_headers — Returns headers for all messages in a mailbox
Returns headers for all messages in a mailbox.
An IMAP stream returned by imap_open().
Returns an array of string formatted with header info. One element per mail message.