$output = '';
foreach ($result as $row) { //здесь делаем двумерный массив
$found = false;
foreach ($result_days as $row_days) {
if ($row['date'] === $row_days['off_date'] && $row_days['off_id'] == 0) { //если выходной
$found = true;
// echo '<span>Выходной день</span><br>';
$sub_hours = (int)$row['sub_hours'];
$output = '
<tr>
<td>' . $row['name'] . '</td>
<td>' . ($sub_hours = $sub_hours - 0) . '</td>
<td>' . $row['date'] . '</td>
<td>Не рабочий день</td>
</tr>';
echo $output;
} else if ($row['date'] === $row_days['off_date'] && $row_days['off_id'] == 1) { //если сокращенка
$found = true;
$sub_hours = (int)$row['sub_hours'];
$sub_hours = $sub_hours - 7;
if ($sub_hours > 0) {
$output = '
<tr>
<td>' . $row['name'] . '</td>
<td>' . $sub_hours . '</td>
<td>' . $row['date'] . '</td>
<td>Сокращенный день</td>
</tr>';
echo $output;
}
}
}
if (!$found) { // рабочие дни
$sub_hours = (int)$row['sub_hours'];
$sub_hours = $sub_hours - 8;
if ($sub_hours > 0) {
$output = '
<tr>
<td>' . $row['name'] . '</td>
<td>' . $sub_hours . '</td>
<td>' . $row['date'] . '</td>
<td>Рабочий день</td>
</tr>';
echo $output;
}
}
}