Jump to content

Contains numerical value


tyrant1337

Recommended Posts

Hi,

Im trying to find out whether a value contains a numerical character in it

i.e. If FY1 1AL then ill do something with it or if its Bleakpool for instance I wont

The code ive found doesnt seem to work

[code]if(preg_match('[0-9]', $value))[/code]

Any comments would help

Cheers
Link to comment
https://forums.phpfreaks.com/topic/15465-contains-numerical-value/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.