everyone! I have a chart for the doctors' work generated by an sql consultation. In it, I have the days that the doctor does not work, and I am showing it in an HTML table. The problem I have is that I can't find a way that instead of showing the days that he doesn't work, it shows the other days that he does work. I have tried with foreach and array diff giving to compare an array with the days of the week by array_search, array_diff but I can't achieve it and if I achieve it I don't know how to show those days in the html table either. To get to the point, what I need is to "replace" those dayOffs with "working days" and show them in my html table So I tried to compare the vector variable with an array with weekdays and with array_diff and to get back the days that are not in the vector variable:
I appreciate your help and thank you in advance
Here's my array
Array
(
[0] => Array
(
[day_off1] => tuesday
[day_off2] => thursday
[day_off3] => monday
[duracion] => 30
[horariostart] => 08:00
[horarioend] => 12:00
[id] => 1
[medico_id] => 1
[servicio_id] => 1
[Apellido] => RODRIGUEZ
[NomServicio] => CLINICA
)
[1] => Array
(
[day_off1] => monday
[day_off2] =>
[day_off3] =>
[duracion] => 60
[horariostart] => 10:00
[horarioend] => 14:00
[id] => 2
[medico_id] => 2
[servicio_id] => 1
[Apellido] => GONZALEZ
[NomServicio] => CLINICA
)
[2] => Array
(
[day_off1] => friday
[day_off2] =>
[day_off3] => wednesday
[duracion] => 30
[horariostart] => 09:00
[horarioend] => 13:00
[id] => 3
[medico_id] => 3
[servicio_id] => 3
[Apellido] => HERNANDEZ
[NomServicio] => UROLOGIA
)
[3] => Array
(
[day_off1] => tuesday
[day_off2] => friday
[day_off3] =>
[duracion] => 30
[horariostart] => 07:00
[horarioend] => 15:00
[id] => 4
[medico_id] => 4
[servicio_id] => 2
[Apellido] => PEREZ
[NomServicio] => ODONTOLOGIA
)
)
and here's How I show this data into html table:
thead>
<tr>
<td>DOCTOR</td>
<td>ESPECIALITY</td>
<td>START TIME</td>
<td>END TIME</td>
<td>INTERVAL</td>
<td>DAYS OFF</td>
</tr>
</thead>
<tbody>
<?php
$resultarray= array();
if (mysqli_num_rows($sql1) > 0 ) {
while ($row = mysqli_fetch_assoc($sql1)) {
echo '<tr>';
$resultarray []= $row;
$vector = [];
$DayOff = array();
$DayOff = $row['DIAS'];
$vector[] = $DayOff;
echo '<td>'.$row['Apellido'].'</td>';
echo '<td>'.$row['NomServicio'].'</td>';
echo '<td>'.$row['horariostart'].'</td>';
echo '<td>'.$row['horarioend'].'</td>';
echo '<td>'.$row['duracion'].'</td>';
echo '<td>'.$row['DIAS'].'</td>';
echo'</tr>';
$contador ++;
}
}
?>
</table>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
?>