string replace multiple -- to single - php code example Example: php replace two spaces with one $output = preg_replace('!\s+!', ' ', $input);