RE: [PHP] how do i remove non html special characters??
| From: | Jason Murray | Date: | Tue, 21 Aug 2001 01:05:00 +0000 |
| Subject: | RE: [PHP] how do i remove non html special characters?? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-63592@lists.php.net to get a copy of this message | ||
> i'm building a registration system, and i want to strip all funky
> character map symbols from the username as well. i know strip_tags()
> gets rid of html, but how do i get rid of them?? :(
>
> i just want simple a-z, A-Z and 0-9 allowed in the username.
You'll want an ereg_replace:
// Strip all invalid characters from the username
$username = ereg_replace("[^0-9A-Za-z]", "", $username);
or:
// Detect invalid characters in the username
if (ereg("[^0-9A-Za-z]", $username))
{
echo "Username contains invalid characters.";
}
Jason