I have tried every solution I have come across and am still not getting any results. I have a comment box and I am trying to remove all repetative new lines or /r/n
from the input.
if (isset($_POST['comment'])) {
$comment = mysql_real_escape_string($_POST['comment']);
$comment = filter_var($comment, FILTER_SANITIZE_STRING);
$comment = nl2br($comment);
//this is where it would remove the new lines
$comment = str_replace("\n", '', $comment);
$comment = str_replace("\r", '', $comment);
if($comment == ""){$error=1;}
}
else{ $error = 1;}
for example someone types in Hello/r/n/r/n World!/r/n it would be saved as Hello/n World/n.