Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created July 14, 2013 06:06
Show Gist options
  • Select an option

  • Save umidjons/5993361 to your computer and use it in GitHub Desktop.

Select an option

Save umidjons/5993361 to your computer and use it in GitHub Desktop.
Replace multiple spaces with one using preg_replace()
<?php
$str = preg_replace('/\s\s+/u', ' ', $str); // no issue with cyrillic letters, because using "u" modifier for UTF-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment