助けが必要な配列の例を次に示します ($MY_ARRAY と呼びましょう)。
Array (
[0] => Array ( [NAME] => 1351449606472 [EMAIL] => aaa@yadda.com [ID] => 996774000001224477 )
[1] => Array ( [NAME] => 1351449605330 [EMAIL] => bbb@yadda.com [ID] => 996774000001224473 )
[2] => Array ( [NAME] => 1351449604318 [EMAIL] => ccc@yadda.com [ID] => 996774000001224469 )
[3] => Array ( [NAME] => 1351449603089 [EMAIL] => ddd@yadda.com [ID] => 996774000001224465 )
[4] => Array ( [NAME] => 1351449602046 [EMAIL] => eee@yadda.com [ID] => 996774000001224461 )
[5] => Array ( [NAME] => 1351449600883 [EMAIL] => fff@yadda.com [ID] => 996774000001224457 )
[6] => Array ( [NAME] => 1351449599840 [EMAIL] => ggg@yadda.com [ID] => 996774000001224453 )
)
次のようにforeachを使用してこれをステップスルーする方法を知っています:(注:質問を単純化するという犠牲を払って実際に何をしているのかを示すために編集しました)。
$aws = curl_init();
$url = "https://email.us-east-1.amazonaws.com/";
curl_setopt($aws, CURLOPT_URL, $url);
curl_setopt($aws, CURLOPT_RETURNTRANSFER, true);
//process data
foreach($MY_ARRAY as $X)
{
//set-up email
$MY_ARRAY = $X['EMAIL'];
$ID = $X['ID'];
$SUBSCRIBER_ENCODE = rawurlencode($SUBSCRIBER);
$HELLO = "";
if (strlen($X['NAME']) == 0)
{
$HELLO = "Subscriber,<br /><br />";
}
else
{
$HELLO = $X['NAME'].",<br /><br />";
}
$EMAIL_BODY_ENCODE = rawurlencode($HELLO.$BODY);
//tune curl vars
$DATE = gmdate('D, d M Y H:i:s e');
$HASH = hash_hmac('sha1', $DATE, $AWSPRI, true);
$KEYS = base64_encode($HASH);
$headers = array();
$headers[] = "Host: email.us-east-1.amazonaws.com";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
$headers[] = "Date: ".$DATE;
$auth = "AWS3-HTTPS AWSAccessKeyId=".$AWSPUB;
$auth .= ",Algorithm=HmacSHA1,Signature=".$KEYS;
$headers[] = "X-Amzn-Authorization: ".$auth;
$MAIL = "Action=SendEmail&Source=".$XROM_ENCODE."&ReturnPath=".$BOUNCE_ENCODE."&Destination.ToAddresses.member.1=".$SUBSCRIBER_ENCODE."&Message.Subject.Data=".$SUBJECT_ENCODE."&Message.Body.Html.Data=".$EMAIL_BODY_ENCODE;
curl_setopt($aws, CURLOPT_POSTFIELDS, $MAIL);
curl_setopt($aws, CURLOPT_HTTPHEADER, $headers);
$resp = curl_exec($aws);
}
//complete log and close curl
curl_close($aws);
だから私がしたいのは、一度に3つずつ配列をステップスルーすることです。