PHP removes excess spaces and keeps only one of multiple consecutive spaces

WBOY
Release: 2016-07-25 08:46:09
Original
1799 people have browsed it
  1. /**
  2. * Only one of multiple consecutive spaces is reserved
  3. *
  4. * @param string $string The string to be converted
  5. * @return unknown
  6. */
  7. static public function merge_spaces ( $string )
  8. {
  9. return preg_replace ( "/s(?=s)/","\1", $string );
  10. }
Copy code

Multiple, PHP


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!