SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: is numeric

Hybrid View

  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is numeric

    Whats a good way to test to see if a variable contains only numbers, or text.

    I got one variable, and I got to do something different with it depending on whether or not it contains text or numbers.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think is_numeric() does what you're looking for.

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    who'da thunk it
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    SitePoint Zealot Overgrow's Avatar
    Join Date
    Jan 2001
    Location
    Your basement
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And people still ask.. "Perl or PHP for the web?"


    Perl version: if ($string=~/(0-9*)/g)

    PHP version if (is_numeric($string))




    I love PHP! (ps. my perl regexp might be bunk :-)

  5. #5
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, PHP is nice, but what are the advantages Perl has over PHP? I know php makes it easy to do the hard things with perl but it also makes some of the easy things with perl hard with PHP.

    So basically what I'm asking is what should I learn about perl? I'm just a PHP guy. But I want to learn things in other languages that I can't do with PHP. I know a bit of javascript, but then the tutorial started getting into the real scripting and if statements and stuff. So I stopped there because I knew how to do that with PHP.

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I found that PERL is way better for doing mundane server admin tasks, like manipulating files, etc.. especially when invoked from the commandline. But PHP is definitely better for the web stuff.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found PERL excellent at file manipulation as freddu said, and it is awesome if you are going to create a webadmin control panel for a website.... because it is more of a true programming language then PHP, it has abroader spectrum of usefullness. Both are wonderfull in their respective fields of use.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services


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
  •