Home > Backend Development > PHP Tutorial > php正则有办法去除第一段空格吗?

php正则有办法去除第一段空格吗?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:51:42
Original
858 people have browsed it

php正则有办法去掉第一段空格吗??

$str="123            脚本之家 www.jb51.ne      ";
Copy after login


最后我需要的是

$str="123脚本之家 www.jb51.ne      ";
Copy after login


有什么办法吗
------解决方案--------------------
$str="123            脚本之家 www.jb51.ne      ";
$p = preg_split ("/\s{2,}/",$str);
var_dump(join($p));
Copy after login

------解决方案--------------------
$str="123            脚本之家 www.jb51.ne      ";
var_dump(preg_replace('/\s+/', '', $str, 1));
Copy after login

string(29) "123脚本之家 www.jb51.ne      "

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