Hello, I have used preg_match in the past to validate a variable by check that it only has numbers and letters. The problem is that I not longer remember what the code was. Does any one know how to use preg_match to only allow numbers and letters in the variable? Thanks! Jay S.
Better using ctype_alnum in this case. p.p.: if (preg_match('#^\w+$#us',$string)) echo $string." consists of all letters or digits"; Code (markup):
Thanks for remark Correct: if (preg_match('#^[a-z0-9]+$#ius',$string)) echo $string." consists of all letters or digits"; PHP: