loinsees Posted April 1, 2007 Share Posted April 1, 2007 code so far: form: <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="remove.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>NewLine Remover </strong></td> </tr> <tr> <td> </td> <td> </td> <td> <textarea name="newlineme" rows="15" cols="40" default=""> </textarea> </td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" value="Submit"></td> </tr> </table> </td> </form> </tr> </table> processor: <?php $string=$_POST['newlineme']; $string = preg_replace('\n', " ", $string); $string = preg_replace('\r', " ", $string); echo $string; ?> What am I missing here? Please help out. Link to comment https://forums.phpfreaks.com/topic/45119-solved-simple-question-removing-newline/ Share on other sites More sharing options...
Barand Posted April 1, 2007 Share Posted April 1, 2007 Use double quotes when using \n \r \t etc. $string = preg_replace("\n", " ", $string); Link to comment https://forums.phpfreaks.com/topic/45119-solved-simple-question-removing-newline/#findComment-219046 Share on other sites More sharing options...
loinsees Posted April 2, 2007 Author Share Posted April 2, 2007 Ahh thanks... turns out I was missing quite a few things Anyways, heres the finished code for remove.php: <?php $string = $_POST['newlineme']; $string = str_replace("\n", "", $string); $string = str_replace("\r", "", $string); $string = stripslashes($string); echo $string; ?> Link to comment https://forums.phpfreaks.com/topic/45119-solved-simple-question-removing-newline/#findComment-219982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.