Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 09:01:58
Original
874 people have browsed it

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

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

textarea回车换行为 \r\n

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

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

或者使用explode也是可以的

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

希望本文所述对大家的php程序设计有所帮助。

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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template