Jump to content

[SOLVED] Problem with using preg_replace()


steve m

Recommended Posts

Hello,

 

I am having a problem trying to use the preg_replace() function.  I have a form and I want to remove "new line(\n)", tabs(\t), carriage returns(\r) etc.. from the data being submitted, but it doesn't seem to work.

<?php
$str = preg_replace("/\n/", '' ", $_POST[email]);

echo $str;

?>

It doesn't seem to do anything.  For example, if the email field is submitted with [email protected]\n and I print $str, it prints [email protected]\\n.

 

Can someone please tell me what I am doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/81628-solved-problem-with-using-preg_replace/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.