3v4l.org

run code in 300+ PHP versions simultaneously
<?php //just generate some test dates $dates = []; for ($i = 1; $i<=7; $i++) { $dates["date0".$i] = "2022-08-0".$i; } extract($dates); $row = array("table_name" => "test", "threshold" => 5); //generate some random test data foreach ($dates as $key => $val) { $row[$val] = rand(0, 10); } var_dump($row); $rowId = 0; $table_rows = array(); //now for the important bit $html = '<tr> <td style="text-align:center"><b>'.$row['table_name'].'</td> <td style="text-align:center;'.($row["$date07"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date07"].'</td> <td style="text-align:center;'.($row["$date06"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date06"].'</td> <td style="text-align:center;'.($row["$date05"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date05"].'</td> <td style="text-align:center;'.($row["$date04"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date04"].'</td> <td style="text-align:center;'.($row["$date03"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date03"].'</td> <td style="text-align:center;'.($row["$date02"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date02"].'</td> <td style="text-align:center;'.($row["$date01"] < $row["threshold"] ? "background-color:red;" : "").'">'.$row["$date01"].'</td> </tr>'; echo $html;

preferences:
24.66 ms | 406 KiB | 5 Q