I am trying to run a for loop that checks for all the values in an array then run an if statement if any any value matches one that is in the array, it skips that value. I have this:
Total Seats
10
$seats_arr = [1, 4, 7]
$result = mysqli_query($con, "SELECT * FROM trains WHERE id='$id'");
while ($row = mysqli_fetch_array($result)) {
$total_seats = $row['seats'];
$booked_seats = $row['booked_seats'];
$viti = $row['viti'];
$seats_arr = preg_split("/\,/", $viti);
print_r($seats_arr);
?>
<select class="custom-select col-12" name="selected_seat">
<option selected="" disabled>Choose your seat</option>
<?php
$N = $total_seats;
foreach ($seats_arr as $seat) {
for($i=1; $i <= $N; $i++) {
if($i == $seat){
continue;
}
?>
<option value="<?php echo $i; ?>"><?php echo "Seat ", $i; ?></option>
<?php
}
}
}
?>
</select>
Desired Output
2, 3, 5, 6, 8, 9, 10