How can you automatically generate line breaks and dashes in PHP?

To automatically generate line breaks and dashes in PHP, you can use the nl2br() function to convert newlines to HTML line breaks (<br>) and str_repeat() function to generate a string of dashes. This can be useful when displaying text with line breaks or separating content with dashes.

&lt;?php
$text = &quot;This is a sample text with line breaks.&quot;;
echo nl2br($text); // Outputs the text with line breaks

$dashLine = str_repeat(&quot;-&quot;, 20); // Generates a line of dashes
echo $dashLine; // Outputs a line of dashes
?&gt;