frijole Posted February 3, 2008 Share Posted February 3, 2008 I would like to check a string to see if the username has any illegal characters, i.e. anything that is not a letter or a number, Any ideas? Quote Link to comment Share on other sites More sharing options...
p2grace Posted February 3, 2008 Share Posted February 3, 2008 This should do the trick: <?php $text = "test123"; if (!ereg('[^A-Za-z0-9]', $text)) { echo "contains only letters and numbers"; }else{ echo "contains invalid characters."; } ?> Quote Link to comment Share on other sites More sharing options...
frijole Posted February 5, 2008 Author Share Posted February 5, 2008 the ereg() function returns the length of string? I read the manual and i do not understand how the !ereg() argument works? can anyone clarify this for me? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.