trim space with pewg_match code example Example: remove double space php $ro = preg_replace('/\s+/', ' ',$row['message']);