I want to iterate array then It should be reset again in PHP . The following logic I want to implement
I have an array of smtp and a second array from which I just want to send email once per smtp . Actually I have a list of array for which I want to send email but I have few smtp hosts . I am iterating a list of array in foreach loop. I have a smtp array in which I have defined certain limit to send email.
function sendmail_test(){
return "Sent<br/>";
}
$email_arrays=array(
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
);
$smtp_array=array(
'[email protected]'=>10,
'[email protected]'=>15
);
$smtp_count=count($smtp_array);
$smtp_counter=0;
for($i=0;$i<=$smtp_count;$i++){
foreach($email_arrays as $ek=>$ev){
print_r($smtp_counter);
echo sendmail_test();
}
$smtp_counter++;
}
Actually I want exactly like this. I have currently have two smtp in $smtp_array
First email should be fired by like this smtp
[email protected] - >'[email protected]'
And second email should be fired by like this
[email protected]',->'[email protected]'
and then third email should be fired like this
[email protected] - >'[email protected]'
which Is then reset and will use first smtp in $smtp_array .. I hope you will get my point now.
$smtp_countis 2 and in the loop you check$i=0;$i<=$smtp_countwhich will loop 3 times for 0, 1 and 2. Is that intended?