The code is as follows |
|
$names = Preg_split ('/rn/', $_post[' textarea ')); foreach ($names as $name) { Todo something Eg:echo $name; } |
The value is very simple, then the assignment, in the TEXTAREA output line break is not so simple
The code is as follows |
|
$vals = Get_from_mydb (); $tmp = '; foreach ($vals as $val) { $tmp. = $val. ' & #13;& #10; '; } |
"and" "is what meaning, because the question of time I don't say, I go to Baidu GG!"
code is as follows |
&nbs P; |
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title>php Gets the line-wrapping problem in the form area data </title> <BODY>&NBSP <?php $content =empty ($_post[' content ') Null:trim ($_post[' content '); if (!empty ($content)) echo str_replace ("R", ' RL ', NL2BR ($content)); echo "R". ' <br/>----------Split Line----------------------'. ' R "; if (!empty ($content)) echo str_replace (" n ", ' NL ', NL2BR ($content)); echo" n ". ' <br/>----------Split Line----------------------'. ' n "; if (!empty ($content))Echo str_replace ("R", ' RL ', Str_replace ("n", ' NL ', NL2BR ($content)); echo "R". <br/>----------Split Line----------------------<br/> '. ' n "; Echo ' Hello '." n ". ' Boys! '; Echo ' Hello '. R ". ' Boys! '; &NBSP ? > <form action= "textareanl.php" method= "post" enctype= "Multipart/form-data" > <textarea name= "content" cols= "rows=" 6 "></TEXTAREA>&NBSP; <br/> <input Type= "Submit" value= "submitted"/>&NBSP; </form> </body> |
After opening in the browser, enter the form in the
:
When submitted, the results are displayed in the browser as follows:
In Notepad cocoa see the following results:
From the above results are visible:
The 1.PHP function nl2br () inserts an HTML newline character before each new line (RN) in the string:
;
2.Windows line wrapping is (RN);
3. In Notepad, R or n all have the function of line-wrapping;