That should be easily possible. I think the manual says something like
$status = imap_status(link, folder, all) or something like that.
So $status->new should give u the no. of new messages.
Check the manual (definitely the online manual has something like this)
Nilesh