I recently studied discuz and found that many backend settings are filled in with textarea and each row is interesting, avoid wasting too much time on the control issues during the settings. Let's just move on to the code: $ namesn... I recently studied discuz and found that many backend settings are filled in with textarea and each row is interesting, avoid wasting too much time on the control issues during the settings.
Let's just move on to the code:
$names = preg_split('/rn/',$_POST['textarea']);foreach($names as $name){ // todo something eg: echo $name;}
The value is very simple, so the value assignment is not that easy to output line breaks in textarea.
$vals = get_from_mydb();$tmp = '';foreach($vals as $val){ $tmp .= $val.'
';}
What does "" and "" mean, because I won't talk about the time, just go to Baidu GG!
PHP retrieves line breaks in form area data
---------- Split line -------------------- '. "r"; if (! Empty ($ content) echo str_replace ("n", 'nl ', nl2br ($ content); echo "n ".'
---------- Split line -------------------- '. "n"; if (! Empty ($ content) echo str_replace ("r", 'rl ', str_replace ("n", 'nl', nl2br ($ content); echo "r ".'
---------- Split line ----------------------
'. "N"; echo 'hello'. "n". 'Boys! '; Echo 'hello'. "r". 'Boys! ';?>
Open in the browser and enter
:
After you press submit, the browser displays the following results:
In Notepad Coco, you can see the following results:
The preceding results show that:
1. the PHP function nl2br () is to insert an HTML line break before each new line (rn) in the string:
;
2. in Windows, the line feed is (rn );
3. in Notepad, r or n has the newline function;
Article URL:
Reprint ^ at will, but please attach the tutorial address.