If $variable is between 0-9.....

Discussion in 'PHP' started by blueparukia, Oct 4, 2007.

  1. #1
    How do you make something like between?

    I want it so that if a variable is between 1 and 9, it outputs one thing, between 10 and 99 another, and if it is over 100, it outputs another.

    Something like if $code > 0 and < 9.....


    Could someone please help me,


    Thanks,

    BP
     
    blueparukia, Oct 4, 2007 IP
  2. ravish_83

    ravish_83 Peon

    Messages:
    221
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if($code >=100){
     echo "above 100";
    }elseif(($code>=10) and ($code<=99)){
      echo " 10 - 99";
    }elseif(($code>=1) and ($code<=9)){
      echo "0 -9";
    }else{
      echo "This is not a number ";
    }
    PHP:
    -Ravish
     
    ravish_83, Oct 4, 2007 IP
    blueparukia likes this.
  3. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #3
    Thank you,

    BP
     
    blueparukia, Oct 4, 2007 IP