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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:00:34
Original
927 people have browsed it

$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
Copy after login

";var_dump($tmp);?>
Copy after login

有比这个更简单的吗?最好一步到位的

$str="123            脚本之家 www.jb51.ne      ";$p = preg_split ("/\s{2,}/",$str);var_dump(join($p));
Copy after login
Copy after login

ok,我看看

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

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

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