$username = preg_replace("/[^\p{L}|\p{N}]/u", "", html_entity_decode($username));
This allows "letters" and "numbers" in the $username
, removing everything else.
But how can I also allow "."
dot symbols in the mix? also "-"
would be nice.
Thank you very much!