我似乎無法弄清楚這一點。我如何將foreach結果存儲在變量中?這是我的代碼。如何將foreach結果存儲在一個變量中並將其用於數組中
$ids = get_field('auction_catalog');
if($ids) {
foreach($ids as $id => $auctionids) {
$string .= $auctionids . ', ';
}
echo $string;
}
上面的結果是:1,2,
但結果我想要得到的是:'1', '2'
我想使用的結果這樣一個數組...
array(
'taxonomy'=> 'auction-catalog',
'field' => 'term_id',
'terms' => array($string) // array('1', '2')
)
提前致謝!
非常感謝!有效! –