Home > Backend Development > PHP Tutorial > PHP实现将textarea的值根据回车换行拆分至数组_php技巧

PHP实现将textarea的值根据回车换行拆分至数组_php技巧

PHP中文网
Release: 2016-05-16 20:14:13
Original
1952 people have browsed it

本文实例讲述了PHP实现将textarea的值根据回车换行拆分至数组的方法。分享给大家供大家参考。具体分析如下:

textarea回车换行为 \r\n

$keyword_list = trim($_REQUEST['keywords']);
$keyword_arr = explode("\r\n", $keyword_list);
Copy after login

这个地方需要注意是要去除textarea 前后的空格,否则会多出一个

或者使用explode也是可以的

只是不能用 \n只能用双引号,不能用单引号

以上就是PHP实现将textarea的值根据回车换行拆分至数组_php技巧的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template