What PHP function can be used to remove line breaks from text output in a table cell?

When outputting text in a table cell in HTML, line breaks can disrupt the layout and formatting of the table. To remove line breaks from text output in a table cell, you can use the PHP `nl2br()` function to convert line breaks to `<br>` tags. This will preserve the line breaks visually without affecting the table layout.

&lt;?php
$text = &quot;This is a text with
line breaks.&quot;;
$clean_text = nl2br($text);

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