glenelkins Posted January 27, 2009 Share Posted January 27, 2009 Here is something iv never had to worry about,but i do now! I need to know how a textarea that posts data to a php script represents a new line so i can explode() the text. I have tried explode ( '\n', $_POST['textarea_field'] ); and that doesnt work it simply puts everything into positon 0 in the array Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/ Share on other sites More sharing options...
rhodesa Posted January 27, 2009 Share Posted January 27, 2009 '\n' is the literal characters \ and n. you need to have double quotes for it register as a new line character edit: so... explode("\n",$_POST['textarea_field']); Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/#findComment-747614 Share on other sites More sharing options...
glenelkins Posted January 27, 2009 Author Share Posted January 27, 2009 ah yeh! stupid me lol...let me give that a go thanks Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/#findComment-747616 Share on other sites More sharing options...
glenelkins Posted January 27, 2009 Author Share Posted January 27, 2009 nope that doesnt work explode ( "\\n", $_POST['textarea_field'] ); its still putting everything into the 0 pointer Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/#findComment-747619 Share on other sites More sharing options...
glenelkins Posted January 27, 2009 Author Share Posted January 27, 2009 actyually sorry its me again, it does work i didnt realise i had put single quotes before... Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/#findComment-747625 Share on other sites More sharing options...
trq Posted January 27, 2009 Share Posted January 27, 2009 Try.... explode(PHP_EOL, $_POST['textarea_field']); Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/#findComment-747631 Share on other sites More sharing options...
rhodesa Posted January 27, 2009 Share Posted January 27, 2009 Try.... explode(PHP_EOL, $_POST['textarea_field']); question on that...isn't the PHP_EOL constant set by the server OS, while the new line in a POST set by the client? Link to comment https://forums.phpfreaks.com/topic/142639-how-a-represents-a-new-line/#findComment-747634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.