8 September 2015

You can replace all whitespaces (space, new lines, etc.) with a single space using regular expression find and replace.

Source code viewer
  1. $output = preg_replace('/\s+/', ' ', $input);
Programming Language: PHP