0
如果条件为false,如何开始foreach
与新项目。 我有这样的代码:开始从开始的foreach
foreach($a_auctions as $auction){
# get the winner
if($auction['for_canada'] == 1 && $isFromCanada){
// another solution to start the foreach with new item (break, exit) ?
$this->a_returnData[] = array(
'winner' => 'pseudo',
'title' => 'title',
'price' => 200,
);
}else{
$this->a_returnData[] = array(
'winner' => 'pseudo',
'title' => 'title',
'price' => 200,
);
}
}
我想在如果开始用foreach的新项目,如果条件不成立,这个想法是为了避免重复的代码。我添加了一条评论。
请你与你的期望的输出更新您的问题 –
请更新您的代码,它是越野车! –
@BunkerBoy我不想在第一个中复制代码...如果可以添加中断或继续? – user7424312