How can nl2br be used to replace line breaks with <br> tags in PHP?
To replace line breaks with <br> tags in PHP, you can use the nl2br() function. This function takes a string as input and replaces all newline characters with <br> tags. This is useful when displaying text that contains line breaks in HTML format.
```php
$text = "This is a text with
line breaks.";
echo nl2br($text);
```
In the above code snippet, the variable $text contains a string with line breaks. The nl2br() function is then used to replace the line breaks with <br> tags when the text is echoed.