To remove the new line the following code is working good;
<?php
$text = "Hello \nwelcome to \ngeeksforgeeks";
$text = str_replace("\n", "", $text);
echo $text;
?>
OUTPUT:Hello welcome to geeksforgeeks.
But when i get it as input it is not working;
<form method="post">
<label>enter string</label> 
<input type="text" name="string"></input><br><br>
<input type="submit" name="enter"></input>
</form>
<?php
if(isset($_POST['enter']))
{
$text=$_POST['string'];
$out=str_replace("\n","",$text);
echo $out;
}
?>
INPUT:Hello \nwelcome to \ngeeksforgeeks;
OUTPUT:Hello \nwelcome to \ngeeksforgeeks.
please tell me the reason