...

View Full Version : Verify that a string is all alphanum and spaces



FeralReason
04-30-2009, 09:50 PM
I'm looking for a PHP function that would return TRUE for a string of alphanumeric characters and spaces and FALSE if there were any characters that were neither alphanum nor spaces.

Any ideas ?

Eran
04-30-2009, 10:08 PM
ctype_punct (http://php.net/manual/en/function.ctype-punct.php)

venegal
05-01-2009, 03:22 AM
Well that's not exactly it. Non-alphanumeric and non-space does not automatically mean punctuation.

Try


ctype_alnum(str_replace(" ", "", $string));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum