Home > Backend Development > PHP Tutorial > PHP怎么删除第一行的空行

PHP怎么删除第一行的空行

WBOY
Release: 2016-06-23 13:36:53
Original
1246 people have browsed it

$_POST = preg_replace("/(\n\s*\r)/i", '', $_POST);


这样做不行
$_POST['vod_url_1'] 的值是

 

今天开始我爱你01$227703131
今天开始我爱你02$227771999
今天开始我爱你03$227863744
今天开始我爱你04无字$227909342


回复讨论(解决方案)

[\n\s\r]+

你 (\n\s*\r) 不行的原因是:\n 必须要在 \r 前面出现。而 windows 中 \r 总是在 \n 前面

$_POST['vod_url_1'] = preg_replace("/($\s*$)|(^\s*^)/m", '', $_POST['vod_url_1']);




测试可用了,用楼上的测试没成功

版主给的是删除所有行,而我要的是删除为空的行

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