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 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";} 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! Link to comment https://forums.phpfreaks.com/topic/31115-newbie-question-str-functions/#findComment-143725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.