Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php foreach循环在另一个循环中_Php_Foreach_Campaign Monitor - Fatal编程技术网

php foreach循环在另一个循环中

php foreach循环在另一个循环中,php,foreach,campaign-monitor,Php,Foreach,Campaign Monitor,我有以下代码: foreach($result->response->Results as $entry) { echo '<tr class="'. $entry->EmailAddress.'">'; echo '<td>'. $entry->EmailAddress.'</td>'; echo '<td></td><td>'; foreach($u

我有以下代码:

foreach($result->response->Results as $entry) { 

    echo '<tr class="'. $entry->EmailAddress.'">';      
    echo '<td>'. $entry->EmailAddress.'</td>';

    echo '<td></td><td>';



foreach($unsubscribers->response->Results as $entry2) { 


echo $entry2->EmailAddress; }

    echo '</td><td></td>';
    echo '<td></td>';
    echo '<td></td>';

    echo '</tr>';

}
foreach($result->response->Results as$entry){
回声';
回显“.$entry->EmailAddress.”;
回声';
foreach($unsubscribers->response->结果为$entry2){
echo$entry2->EmailAddress;}
回声';
回声';
回声';
回声';
}
第一个循环通过campaign monitor api拉入收件人电子邮件地址列表,第二个循环拉入已取消订阅的人

我的问题是,有100个订户被吸引进来,而目前其中1个已经取消了订阅。那个1个退订者被循环了100次,很明显会被显示出来


我如何调整上述内容,使其不显示有多少订阅者。

检查此代码,它可能适合您的方式

foreach($result->response->Results as $entry){ 

    echo '<tr class="'. $entry->EmailAddress.'">';      
    echo '<td>'. $entry->EmailAddress.'</td>';
    echo '</tr>';
}

foreach($unsubscribers->response->Results as $entry2){ 
    echo '<tr class="'. $entry2->EmailAddress.'">';      
    echo '<td>'. $entry2->EmailAddress.'</td>';
    echo '</tr>';
}
foreach($result->response->Results as$entry){
回声';
回显“.$entry->EmailAddress.”;
回声';
}
foreach($unsubscribers->response->结果为$entry2){
回声';
回显“.$entry2->EmailAddress.”;
回声';
}

检查此代码,它可能适合您的方式

foreach($result->response->Results as $entry){ 

    echo '<tr class="'. $entry->EmailAddress.'">';      
    echo '<td>'. $entry->EmailAddress.'</td>';
    echo '</tr>';
}

foreach($unsubscribers->response->Results as $entry2){ 
    echo '<tr class="'. $entry2->EmailAddress.'">';      
    echo '<td>'. $entry2->EmailAddress.'</td>';
    echo '</tr>';
}
foreach($result->response->Results as$entry){
回声';
回显“.$entry->EmailAddress.”;
回声';
}
foreach($unsubscribers->response->结果为$entry2){
回声';
回显“.$entry2->EmailAddress.”;
回声';
}

你的意思是这样的吗

// Add the unsubscribers to an array
$unsubs = array();
foreach($unsubscribers->response->Results as $entry2) {
    $unsubs[] = $entry2->EmailAddress;
}

// Loop through the subscribers
foreach($result->response->Results as $entry) { 

    echo '<tr class="'. $entry->EmailAddress.'">';      
    echo '<td>'. $entry->EmailAddress.'</td>';
    echo '<td></td><td>';

    // If the subscriber is in our unsubscriber array, output the email again
    if(in_array($entry->EmailAddress, $unsubs)) { 
        echo $entry->EmailAddress;
    }

    echo '</td><td></td>';
    echo '<td></td>';
    echo '<td></td>';
    echo '</tr>';

}
//将取消订阅者添加到数组中
$unsubs=array();
foreach($unsubscribers->response->Results as$entry2){
$unsubs[]=$entry2->EmailAddress;
}
//在订阅者中循环
foreach($result->response->Results as$entry){
回声';
回显“.$entry->EmailAddress.”;
回声';
//如果订户在我们的取消订户阵列中,请再次输出电子邮件
如果(在数组中($entry->EmailAddress,$unsubs)){
echo$entry->EmailAddress;
}
回声';
回声';
回声';
回声';
}

如果该订阅者也在unsubscribers数组中,它将只在第二列中输出电子邮件

您的意思是这样的吗

// Add the unsubscribers to an array
$unsubs = array();
foreach($unsubscribers->response->Results as $entry2) {
    $unsubs[] = $entry2->EmailAddress;
}

// Loop through the subscribers
foreach($result->response->Results as $entry) { 

    echo '<tr class="'. $entry->EmailAddress.'">';      
    echo '<td>'. $entry->EmailAddress.'</td>';
    echo '<td></td><td>';

    // If the subscriber is in our unsubscriber array, output the email again
    if(in_array($entry->EmailAddress, $unsubs)) { 
        echo $entry->EmailAddress;
    }

    echo '</td><td></td>';
    echo '<td></td>';
    echo '<td></td>';
    echo '</tr>';

}
//将取消订阅者添加到数组中
$unsubs=array();
foreach($unsubscribers->response->Results as$entry2){
$unsubs[]=$entry2->EmailAddress;
}
//在订阅者中循环
foreach($result->response->Results as$entry){
回声';
回显“.$entry->EmailAddress.”;
回声';
//如果订户在我们的取消订户阵列中,请再次输出电子邮件
如果(在数组中($entry->EmailAddress,$unsubs)){
echo$entry->EmailAddress;
}
回声';
回声';
回声';
回声';
}

如果该订阅者也在unsubscribers数组中,它将只在第二列输出电子邮件

将取消订阅移出另一个循环,但我希望它们位于第一个循环生成的同一表行将取消订阅移出另一个循环,但我希望它们位于第一个循环生成的同一表行