其实我有三个foreach循环。当第三个foreach循环值($ val == $ test)匹配时,我想跳过第二个foreach循环。 这是我的代码。如何在codeigniter中匹配值时跳过foreach循环
<tbody>
<?php foreach ($tests as $test): ?>
<tr>
<td><?= $test; ?></td>
<?php foreach ($room as $key => $value): ?>
<?php foreach ($value['dates'] as $val) : ?>
<?php if ($val == $test) { ?>
<td><span class="text-danger"><?= $value['room_id'];?</span></td>
<?php } ?>
<?php endforeach; ?>
<td><span class="text-custom"><?= $value['room_id']; ?></span></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
@Saty不是'继续'吗? –
你的意思是,如果$ val == $ test那么它应该去第一个foreach意味着$房间是一个吗? – rahulsm
我会完全失去第三个循环 - 唯一的区别是类名。看看使用'in_array'这样的东西来查看'$ test ['dates']是否存在'$ test' - 如果是的话就改变类。 – Tom