watts Posted December 18, 2006 Share Posted December 18, 2006 This may be a stupid question but is there a way for me to check if a string contains numbers? I'm trying to do a form validation where I can make sure that certain fields only contain letters or numbers.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/31115-newbie-question-str-functions/ Share on other sites More sharing options...
ToonMariner Posted December 18, 2006 Share Posted December 18, 2006 yep$str = " some words and some 8734 0387";if (preg_match('/[0-9]/', $str)){ echo "its got numbers";} Quote Link to comment https://forums.phpfreaks.com/topic/31115-newbie-question-str-functions/#findComment-143659 Share on other sites More sharing options...
watts Posted December 18, 2006 Author Share Posted December 18, 2006 Thanks,That did the trick! Quote Link to comment https://forums.phpfreaks.com/topic/31115-newbie-question-str-functions/#findComment-143725 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.