Home > php教程 > php手册 > php:去掉多余的空行

php:去掉多余的空行

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:53:43
Original
1931 people have browsed it

?php $str=iamabook\n\n\n\n\nmoth; //去除所有的空和换行符 echopreg_replace(/[\s]{2,}/,,$str).'br'; //去除多余的空和换行符,只保留一个 echopreg_replace(/([\s]{2,})/,\\1,$str); //去除多余的空或换行$text = preg_replace(/(\r\n|\n|\r|\t)/i, '',


$str="i   am    a     book\n\n\n\n\nmoth";
//去除所有的空格和换行符
echo preg_replace("/[\s]{2,}/","",$str).'
';

//去除多余的空格和换行符,只保留一个

echo preg_replace("/([\s]{2,})/","\\1",$str);

//去除多余的空格或换行 $text = preg_replace("/(\r\n|\n|\r|\t)/i", '', $text);

$lastSeveralLineContentsArr = preg_replace("/([ |\t]{0,}[\n]{1,}){2,}/","",$lastSeveralLineContentsArr);//对Html里有连续的空行或tab给正则过滤掉>

?>
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template