In what scenarios is it recommended to use rtrim() instead of trim() for textareas or specific input fields?

When dealing with textareas or specific input fields where you want to remove trailing whitespace only on the right side of the text, it is recommended to use rtrim() instead of trim(). This is useful when you want to preserve leading whitespace but remove trailing whitespace, such as when dealing with code snippets or formatted text.

// Example of using rtrim() on a textarea input field
$text = $_POST['textarea_input']; // Get the input from the textarea
$trimmed_text = rtrim($text); // Remove trailing whitespace only on the right side

// Now $trimmed_text contains the input with trailing whitespace removed on the right side