Skip to content

Instantly share code, notes, and snippets.

@plasticbrain
Created September 11, 2012 23:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plasticbrain/3702974 to your computer and use it in GitHub Desktop.
Save plasticbrain/3702974 to your computer and use it in GitHub Desktop.
PHP: (REGEX/preg_replace) replace multiple characters (ie: spaces)
//--------------------------------------------------------------------------
// Replace multiple spaces with a single space
// Substitute "\s\s" with whatever characters you want to check for
//--------------------------------------------------------------------------
$text = preg_replace("/\s\s+/", ' ', $text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment