Are there any best practices to follow when dealing with line breaks in PHP variables?

When dealing with line breaks in PHP variables, it's important to normalize line breaks to a consistent format to avoid unexpected behavior when working with the data. One common approach is to use the PHP `str_replace()` function to replace different types of line breaks with a standard format, such as `\n`.

// Normalize line breaks in a PHP variable
$text = "Hello\r\nWorld!";
$normalized_text = str_replace(["\r\n", "\r"], "\n", $text);

echo $normalized_text;