tyrant1337 Posted July 24, 2006 Share Posted July 24, 2006 Hi,Im trying to find out whether a value contains a numerical character in iti.e. If FY1 1AL then ill do something with it or if its Bleakpool for instance I wontThe code ive found doesnt seem to work[code]if(preg_match('[0-9]', $value))[/code]Any comments would helpCheers Quote Link to comment Share on other sites More sharing options...
Braet Posted July 24, 2006 Share Posted July 24, 2006 newb myself, but:[code]<?php$value="473";if(ereg("[0-9]", $value)) {echo "yup";}echo $value;die();?>[/code]does work no matter the number 4 or 473 (and will not return the "yup" if it has no number. Per php.net, preg_match is usually faster though - I do not know if ereg will suit your needs - but perhaps that will steer you in a direction suited to what you are attempting. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 24, 2006 Share Posted July 24, 2006 PREG needs delimiters; try /\d/. 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.