php - 如何在html文本区域中逐句获取字符串

标签 php javascript html string textarea

我有一个文本区域,其中包含以下信息,

Secured places in the national squad respectively
Selected to the national team this year as well
Selected to the national team twice during his university career
Went to school at ABS 

当用户单击提交按钮时,我想将每行中的字符串获取到提交页面中的 php 变量,如下所示

$a = "Secured places in the national squad respectively";
$b = "Selected to the national team this year as well";
$c = "Selected to the national team twice during his university career";
$d = "Went to school at ABS";

谁能告诉我该怎么做?

最佳答案

如果您不关心句子而是换行符,那么您应该能够基于它来分成数组,如下所示:

$posted_text = $_POST['text']; // or however you get the value into a string
$text_array = explode(PHP_EOL, $posted_text);

关于php - 如何在html文本区域中逐句获取字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12063024/

相关文章:

php - 返回 mysql 中单个结果中与某个 id 匹配的所有行

php - Android、php、MySQL 和 phpMyAdmin

PHP 301 重定向,不可能?

php - 函数中的全局 PHP 类?

javascript - React Array Prop 在渲染时发生变化

javascript - 在 Firefox 和 Chrome 的左侧显示 iframe 滚动条

javascript - 根据用户输入的内容创建数组

javascript - 从另一个 Stencil JS 库导入 Stencil JS 库

javascript - 根据 slider 的值将不同的数据推送到数组

html - 如果文本太短,如何将文本环绕在 float 的 div 周围,因为它不起作用?