convinceme Posted October 9, 2007 Share Posted October 9, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72420-solved-echo-data-on-seperate-lines/ Share on other sites More sharing options...
uladk Posted October 9, 2007 Share Posted October 9, 2007 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; Quote Link to comment https://forums.phpfreaks.com/topic/72420-solved-echo-data-on-seperate-lines/#findComment-365217 Share on other sites More sharing options...
uladk Posted October 9, 2007 Share Posted October 9, 2007 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72420-solved-echo-data-on-seperate-lines/#findComment-365229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.