SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict y_oda2002's Avatar
    Join Date
    May 2005
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    matching numbers

    Hi everyone,

    I am not very good with regular expressions....
    just havent used them enough...

    I need to make sure a string only contains numbers

    how do I do that?


    is it
    eregi($somevar, '^[0-9]+$');

    thanks

    Nick
    Nicholas Rhodes
    Asgard Development
    http://www.asgard-dev.com

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if(ctype_digit($somevar))
    {
    //it's all numbers
    }
    else
    {
    //it isn't
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •