What are the potential pitfalls of using nl2br in conjunction with textareas in PHP?

When using nl2br with textareas in PHP, the newline characters (\n) in the textarea content will be converted to <br> tags when displayed. This can lead to unexpected formatting issues if the content is later submitted back to the server, as the <br> tags may interfere with the newline characters. To solve this issue, you can use nl2br when displaying the content, but strip_tags when processing the form submission to remove any HTML tags.

// Displaying textarea content with nl2br
echo nl2br($textarea_content);

// Processing form submission with strip_tags
$cleaned_content = strip_tags($_POST[&#039;textarea_content&#039;]);