PHP regular expression examples

Replace multiple spaces with one space

See the following code:

<?php
  $str = 'This    string    has   many   spaces';
  $str = preg_replace('/\s+/', ' ', $str);
  print $str;
?>

output

This string has many spaces
Technologies: