explode textarea php (at new lines)

走远了吗. 提交于 2019-11-28 04:58:51

This will do the trick given \r\n, \r or \n:

preg_split('/\r\n|[\r\n]/', $_POST['thetextarea'])

You should use:

explode("\r\n", $_POST['thetextarea']);

It will always be the same.

Browsers and other user-agents will make sure they are :-)

See http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1 for more info.

You could also use the PHP_EOL constant:

explode(PHP_EOL, $_POST['thetextarea']);
Jatin Babbar

You can do something like this:

$text = trim($_POST['textareaname']);
$text = nl2br($text);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!