What is the best practice for removing "CRLF line terminators" from a file when saving data from a form in PHP?

When saving data from a form in PHP, it is common to encounter "CRLF line terminators" that can cause issues when reading or processing the data. To remove these line terminators, you can use the PHP function `str_replace` to replace the CRLF characters with an empty string before saving the data to a file.

// Get the form data
$form_data = $_POST['form_data'];

// Remove CRLF line terminators
$cleaned_data = str_replace("\r\n", "", $form_data);

// Save the cleaned data to a file
$file = fopen('data.txt', 'w');
fwrite($file, $cleaned_data);
fclose($file);