search
Homephp教程php手册PHP实现将textarea的值根据回车换行拆分至数组

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

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

textarea回车换行为 \r\n

1

2

$keyword_list = trim($_REQUEST['keywords']);

$keyword_arr = explode("\r\n", $keyword_list);

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

或者使用explode也是可以的

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

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.