0
<?php
foreach ($array['response']['data']['Offers'] as $arr) {
    $gegevens = array(
        $arr['Offer']['id'],
        $arr['Offer']['name'],
        $arr['Advertiser']['company'],
        $arr['Offer']['advertiser_id'],
        $arr['Offer']['offer_url'],
        $arr['Offer']['default_payout'],
        $arr['Offer']['expiration_date']
    );
    echo '<tr>';
    foreach ($gegevens as $value) {
        echo "<td>{$value}</td>";
    }
    echo "</tr>\n";
}
?>

这是我的代码。如何在 中搜索两种值foreach($array['response']['data']

它必须是foreach($array['response']['data'][**Offers**]并且也是foreach($array['response']['data'][**Advertisers**]

我需要这个,以便我可以回显$arr['**Offer**']['name']$arr['**Advertiser**'] ['company']

有人可以帮我弄这个吗?

4

2 回答 2

0

听起来您不需要将它们全部放入数组中。这应该足够了:

<?php
    foreach($array['response']['data']['Offers'] as $arr) {
        echo '<tr>';
        echo "<td>{$arr['Offer']['name']}</td>";
        echo "<td>{$arr['Advertiser']['company']}</td>";
        echo "</tr>\n";
    }
?>
于 2013-05-02T13:24:15.403 回答
0

最简单的:

foreach($array['response']['data']['Offers'] as $key => $offer_arr){
    $advertiser_arr = $array['response']['data']['Advertisers'][$key];
}

然后,您拥有相同索引的报价数组和广告客户数组

于 2013-05-02T13:12:53.480 回答