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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.