RE: [PHP] Alphanumeric Strings

From: Date: Thu, 14 Sep 2000 23:50:06 +0000
Subject: RE: [PHP] Alphanumeric Strings
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16868@lists.php.net to get a copy of this message
> if (ereg('[^ [:alnum:]]', $string)) { > echo "Contains non-alphanumeric/space characters"; > } else { > echo "Contains only alphanumerics and spaces"; > } Hi, I just put this into my code, because I need something that checks for alphanumeric values too. But it didn't allow for the underscore "_". So I added that into the ereg line and it works with the underscore: if (ereg('[^[:alnum:][_]]', $string)) { blah } Sam

« previous php.general (#16868) next »