PHP & how to trim, replace tabs and extra spaces with single spaces September 17, 2017 September 17, 2017 $data = preg_replace('/[ ]{2,}|[\t]/', ' ', trim($data)); Share this:Click to share on Twitter (Opens in new window)Click to email a link to a friend (Opens in new window)Like this:Like Loading... Related Previous PostPHP & how to trim white space on beginning and the end of each new line with Next PostMySQL UTC timestamp