Jump to content

[SOLVED] simple question... removing newline...


loinsees

Recommended Posts

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

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;
?>

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.