ray-solomon
asked on
echo new line in textarea
If I type:
1
2
3
into the first textarea box and submit it to a second textarea box, I get:
1<br />
2<br />
3
while using this to process it: $output = str_replace("\n", '', nl2br($input));
I just want the second box to be the same as the first. How do I do this?
Like this:
1
2
3
1
2
3
into the first textarea box and submit it to a second textarea box, I get:
1<br />
2<br />
3
while using this to process it: $output = str_replace("\n", '', nl2br($input));
I just want the second box to be the same as the first. How do I do this?
Like this:
1
2
3
Just use:
$output = $input;
$output = $input;
ASKER
Sorry, let me refine my question. I saw you posted to faster than me editing this question.
I am trying to make the output look like this:
1
2
3
"1"
"2"
"3"
[1]
[2]
[3]
I am trying to make the output look like this:
1
2
3
"1"
"2"
"3"
[1]
[2]
[3]
ASKER
I tried using this, but it does not work properly.
echo $output."\n".""".$outp
result:
1
2
3
"1
2
3"
[1
2
3]
ASKER
Here is how I am getting the form values:
foreach ($_POST as $key => $value) {
$kw = $$key = trim($value);
}
if (isset($_POST['field1'])) { $output = $kw; }
foreach ($_POST as $key => $value) {
$kw = $$key = trim($value);
}
if (isset($_POST['field1'])) { $output = $kw; }
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$output = str_replace("\n", '', nl2br($input));
It replaces \n (which is a newline) to <br />