What potential issue could arise when using nl2br function in PHP?
When using the nl2br function in PHP, a potential issue could arise if the input contains both Windows and Unix style line breaks. This can result in unexpected behavior as nl2br only converts Unix style line breaks (\n) to HTML line breaks (<br>). To solve this issue, you can first normalize the line breaks to Unix style before using nl2br.
$input = "Hello\r\nWorld"; // Input with mixed line breaks
$input = str_replace("\r\n", "\n", $input); // Normalize line breaks to Unix style
$output = nl2br($input); // Convert Unix style line breaks to HTML line breaks
echo $output; // Output: Hello<br>World