// fix extra whitespace and invisible ascii stuff $username = trim(preg_replace('#[\r\n\t]+#si', ' ', strip_blank_ascii($username, ' ')));