Skip to content

Instantly share code, notes, and snippets.

@adityadees
Last active September 9, 2021 08:54
Show Gist options
  • Save adityadees/bb805e9b11149b78acc9aee8cdb69cf5 to your computer and use it in GitHub Desktop.
Save adityadees/bb805e9b11149b78acc9aee8cdb69cf5 to your computer and use it in GitHub Desktop.
BUS SEAT PATTERN PHP
$divide = 4;
$inside = 2;
echo "<table border='1'>";
for($i = 1; $i <= 45; $i++){
if($i % $divide == 1 && $i != 45){
echo "<tr>";
}
echo "<td width='15%' align='center'>".$i."</td>";
if($i % $inside == 0 && $i % $divide != 0 && $i != 42){
echo "<td width='40%'>&nbsp;</td>";
}
if($i % $divide == 0 && $i != 44){
echo "</tr>";
}
}
echo "</table>";
$divide = 4;
$inside = 2;
echo "<table border='1'>";
for($i = 1; $i <= 40; $i++){
if($i % $divide == 1){
echo "<tr>";
}
echo "<td width='15%' align='center'>".$i."</td>";
if($i % $inside == 0 && $i % $divide != 0){
echo "<td width='40%'>&nbsp;</td>";
}
if($i % $divide == 0){
echo "</tr>";
}
}
echo "<tr>";
for ($i = 41; $i <= 45; $i++) {
echo "<td width='15%' align='center'>".$i."</td>";
}
echo "</tr>";
echo "</table>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment