連想配列内でどれか一つでも要素が存在するかをチェック
コード
<?php
$fruits_data = [$fruits['apple'],$fruits['grape'],$fruits['peaches'],$fruits['orange']];?>
if(!empty(array_filter($fruits_data))){?>
<table>
<tr>
<th>りんご</th>
<th>ぶどう</th>
<th>ピーチ</th>
<th>オレンジ</th>
</tr>
<tr>
<td><?php echo $fruits['apple']?:'売り切れ'; ?></td>
<td><?php echo $fruits['grape']?:'売り切れ'; ?></td>
<td><?php echo $fruits['peaches']?: '売り切れ'; ?></td>
<td><?php echo $fruits['orange']?: '売り切れ'; ?></td>
</tr>
</table><?php
}?>