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 Link to comment https://forums.phpfreaks.com/topic/15465-contains-numerical-value/ 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. Link to comment https://forums.phpfreaks.com/topic/15465-contains-numerical-value/#findComment-62802 Share on other sites More sharing options...
effigy Posted July 24, 2006 Share Posted July 24, 2006 PREG needs delimiters; try /\d/. Link to comment https://forums.phpfreaks.com/topic/15465-contains-numerical-value/#findComment-62843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.