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