In what ways can PHP be used to programmatically handle line breaks for text displayed in a table?

When displaying text in a table, line breaks can disrupt the layout and readability of the table. One way to handle line breaks programmatically in PHP is to use the `nl2br()` function, which converts newline characters to HTML `<br>` tags. By using this function, line breaks in the text will be properly displayed in the table without disrupting the layout.

&lt;?php
$text = &quot;This is a text with\nline breaks.&quot;;
$text_with_br = nl2br($text);

echo &quot;&lt;table&gt;&quot;;
echo &quot;&lt;tr&gt;&quot;;
echo &quot;&lt;td&gt;&quot;.$text_with_br.&quot;&lt;/td&gt;&quot;;
echo &quot;&lt;/tr&gt;&quot;;
echo &quot;&lt;/table&gt;&quot;;
?&gt;