What potential issues should be considered when using wordwrap() in PHP, especially in relation to layout changes?

When using wordwrap() in PHP to wrap long lines of text, one potential issue to consider is that it can affect the layout of your content, especially in cases where the wrapped text may cause unexpected line breaks or spacing issues. To prevent this, you can use the PHP function nl2br() to insert HTML line breaks <br> after each newline character in the wrapped text, ensuring that the layout remains consistent.

&lt;?php
$text = &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&quot;;
$wrapped_text = wordwrap($text, 20, &quot;\n&quot;, true);
echo nl2br($wrapped_text);
?&gt;