Jump to content

Recommended Posts

I have been trying to display the result from the textarea on seperate lines for e.g

if i enter

a

b

c

in the text area it should display the same rather than what it is doing write now "a b c"

Can someone please help me with this?

 

<?php
$action = $_REQUEST['action'];
if ($action == submit) {
print str_replace("\n", "", $_POST['testt']);
}
echo "<form method=post action=?action=submit>";
echo "<textarea name=testt></textarea>";
echo "<input type=submit name=test value=test></form>"
?>

 

I even tried looking in the search area and found this link but that doesn't help either:

http://www.phpfreaks.com/forums/index.php/topic,92732.msg542113.html#msg542113

Link to comment
https://forums.phpfreaks.com/topic/72420-solved-echo-data-on-seperate-lines/
Share on other sites

This works for what you need:

 

<?php
$action = $_REQUEST['action'];
if ($action == submit) {
  $multiple_lines = nl2br($_POST['testt']);
  echo $multiple_lines;
}
echo "<form method=post action=?action=submit>";
echo "<textarea name=testt></textarea>";
echo "<input type=submit name=test value=test></form>";
?>

 

Edit:

You can interchange echo and print depending on what you want to use:

print $multiple_lines;

You can also use the following if you don't want to store the result in a variable:

 

<?php
$action = $_REQUEST['action'];
if ($action == submit) {
  print nl2br($_POST['testt']);
}
echo "<form method=post action=?action=submit>";
echo "<textarea name=testt></textarea>";
echo "<input type=submit name=test value=test></form>";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.