Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Why won't this work?

    PHP Code:
    elseif ($fmtext == /[^0-9]/ or $fmcheckbox == /[^0-9]/) { 
    ??

    Thanks!

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by cyphix
    PHP Code:
    elseif ($fmtext == /[^0-9]/ or $fmcheckbox == /[^0-9]/) { 
    ??

    Thanks!
    else if are two words, not one.

    Sadiq.

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it doesn't work because you are trying to compaire against the part of a regex.

    aren't rou trying to see if the values are numeric? then it's
    PHP Code:
    elseif (is_numeric($fmtext) or is_numeric($fmcheckbox)) { 
    <edit> elseif is just fine </edit>
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Yeah.. the actual elseif statement works fine like that, it'd the regex parts I was having trouble with.

    If I use "is_numeric" doesn't that allow decimals tho?

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you only want integers, you can use is_int
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Ok, thnaks!

  • #7
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts

    and for some additional knowledge

    preg_match is the (prefferrrd by me) regular expression engine in php. here are the docs:
    http://www.php.net/manual/en/ref.pcre.php
    http://www.php.net/manual/en/ref.regex.php
    "There is more than one way to do it."

  • #8
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Cheers dswimboy!


  •  

    Posting Permissions

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