在每行[PHP和TextArea HTML]中添加后缀



问候是否可以使用PHP从TextArea中的每一行添加后缀?我知道我们可以从Textarea到变量的文本,然后?如何将enter-(新行)添加为变量?

这有效:

<form method="GET">
<textarea name="inputFromTextArea">This is line 1
This is line 2
...
This is line 4</textarea>
<input type="submit">
</form>
<?php 
/* Convert text with lines to an array (rn = Carriage return & Newline on Windows machines*/
$lines = explode("n", $_GET['inputFromTextArea']);
/* debug information to show the contents of $lines */
echo "<pre>";
print_r($lines);
echo "</pre>";
/* Loop over all lines and manipulate each line */
foreach($lines as $lineNr => $line){
    $lines[$lineNr] = trim($line,"r") . " a suffix here "; // remove possible Carriage returns & concatenate stuff
}
/* debug information to show the contents of $lines */
echo "<pre>";
print_r($lines);
echo "</pre>";
?>

阅读有关马车返回的更多信息。这里的新线: r n = n和 r?

之间的差异

最新更新