lynxus Posted September 7, 2009 Share Posted September 7, 2009 Hi guys, I have a multiline textbox, How do i send it to my php script as multiline? The ling is whne i send it to a php script the varable doesnt contain the linebreaks. Im probably looking at this wrong however im sure its a simple solution. Anyideas? Link to comment https://forums.phpfreaks.com/topic/173401-solved-send-multiline-textbox/ Share on other sites More sharing options...
dave_sticky Posted September 7, 2009 Share Posted September 7, 2009 Just use the PHP function nl2br() So... echo nl2br($_POST['textarea']); Link to comment https://forums.phpfreaks.com/topic/173401-solved-send-multiline-textbox/#findComment-914090 Share on other sites More sharing options...
lynxus Posted September 7, 2009 Author Share Posted September 7, 2009 Humm, Doesnt seme to work with a Var. ie: nl2br($string); I can see that it must have linebreaks in it as its stored with them in the DB also ( so its not just one one line in the db either ) Any clues? Ie: in the db it shows: Line1 Line2 Line3 IN the HTML it shows Line1 Line2 Line3 When displayed , it shows: Line1 Line2 Line3 Somehow i need to identify how everything else is seeing it as a newline apart from the echo? Thanks G Link to comment https://forums.phpfreaks.com/topic/173401-solved-send-multiline-textbox/#findComment-914092 Share on other sites More sharing options...
dave_sticky Posted September 7, 2009 Share Posted September 7, 2009 If you wanted to set it as a Var rather than echo it you'd need to do $string = nl2br($string); I'd be very surprised if it doesn't work, because this function exists in both PHP 4 and 5... Link to comment https://forums.phpfreaks.com/topic/173401-solved-send-multiline-textbox/#findComment-914095 Share on other sites More sharing options...
lynxus Posted September 7, 2009 Author Share Posted September 7, 2009 Ah ok that works YAY thanks. bit odd why i cant just echo it directly ratherthan pushing it through itself first. But yay. It works Thanks Graham Link to comment https://forums.phpfreaks.com/topic/173401-solved-send-multiline-textbox/#findComment-914098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.