problem with for loop

[email protected] (Richard Kurth)
Newsgroups php.general
Message-ID <[email protected]>
Way does my for loop not complete the task if there are 4 emails it only 
process 3 emails through the foreach loop if there is 3 it only process 2

     #  Connect up
     $host ="domain.com";
     $port ="110";
     $mailtype = "pop3";
     $mailbox ="INBOX";
     $username ="[email protected]";
     $password ="boat1234";
    
     $conn = @imap_open("{" . $host . ":" . $port . "/" . $mailtype . 
"/notls}" . $mailbox, $username, $password);

$number=imap_num_msg($conn);
for($i = 1; $i <= $number; $i++) {
$file="C:\web\bouncehandler\eml\em$i";
imap_savebody($conn,$file,$i);


$file=file_get_contents("C:\web\bouncehandler\eml\em$i");
$multiArray = Bouncehandler::get_the_facts($file);

 $EMAIL = $the['recipient'];
foreach($multiArray as $the){
        switch($the['action']){
        case 'failed':
        $sql="UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE 
emailaddress = '$EMAIL'";
        mysql_query($sql) or die("Invalid query: " . mysql_error());    
        break;
        case 'transient':
        $sql="UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL'";
        mysql_query($sql) or die("Invalid query: " . mysql_error());
        break;
        case 'autoreply':
        $sql="UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL'";
        mysql_query($sql) or die("Invalid query: " . mysql_error());
        break;
        default:
        //don't do anything
        break;
        }
    }

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.