<?php
// Sample data
$carNumbers = array('123', '123', '345', '345', '567');
// Initialize serial number
$serialNumber = 1;
// Initialize previous car number
$prevCarNumber = null;
// Output the table
echo "<table border='1'>
<tr>
<th>Sr.No</th>
<th>Car No</th>
<th>Allocation From Date</th>
<th>Allocation to Date</th>
</tr>";
// Loop through car numbers
foreach ($carNumbers as $carNumber) {
// If the car number is different from the previous one, increment serial number
if ($carNumber !== $prevCarNumber) {
$prevCarNumber = $carNumber;
echo "<tr><td>$serialNumber</td><td>$carNumber</td><td>01-04-2024 15:00</td><td>12-04-2024 15:00</td></tr>";
$serialNumber++;
} else {
// If the car number is the same as the previous one, output a blank space for serial number
echo "<tr><td></td><td>$carNumber</td><td>01-04-2024 15:00</td><td>12-04-2024 15:00</td></tr>";
}
}
echo "</table>";
?>
Comments
Post a Comment