How can one prevent long strings from distorting the layout in PHP when displaying text from a database within a table?

Long strings can distort the layout in PHP when displaying text from a database within a table by causing the table cells to expand beyond their intended width. To prevent this, you can use the CSS property `word-wrap: break-word;` to force long strings to wrap within the table cell.

echo '<table>';
while($row = mysqli_fetch_assoc($result)) {
    echo '<tr>';
    echo '<td style="word-wrap: break-word;">' . $row['long_text_column'] . '</td>';
    echo '</tr>';
}
echo '</table>';