In a dynamically generated table in PHP, how can a fixed width be applied to ensure consistent design and alignment of the output?

When generating a table dynamically in PHP, it can be challenging to ensure consistent design and alignment of the output, especially when the content varies in length. To address this, you can apply a fixed width to the table cells by setting the width attribute in the HTML output. This will help maintain a uniform appearance regardless of the content length.

echo '<table>';
foreach ($data as $row) {
    echo '<tr>';
    echo '<td style="width: 100px;">'.$row['column1'].'</td>';
    echo '<td style="width: 150px;">'.$row['column2'].'</td>';
    echo '</tr>';
}
echo '</table>';