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 X (Opens in new window) X Click to email a link to a friend (Opens in new window) Email 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