PHP - 在脚本中处理textarea表单的每一行

I've learned it's possible to trim a string from a textarea and put break tags after it, so each sentence written at a new line in the textbox will also be written at a new line in the PHP file.

This is the snippet:

<html>
<body>

<?php
$text = trim($_POST['textarea']);
$text = nl2br($text);
echo $text;
?>

</body>
</html>

The thing is that my true intentions are:

  1. Use the contents of each line in the textbox for a certain script
  2. Print the contents of each line with the results from the script added all seperated by lines.

Thanks in advance.

<?php
    $text = trim($_POST['textarea']);
    $text = explode ("
", $text);

    foreach ($text as $line) {
       echo myFunction($line);
       echo "< hr />";
    }
?>

The PHP function explode lets you take a string and blow it up into smaller pieces. Store this array for use in other scripts

$str_arr = explode("
", $_POST['textarea']);
//$str_arr can be used for other script