How can I get the last 2 digits of a variable and put it in another variable?

Discussion in 'PHP' started by ImpulseHorizon, Apr 27, 2008.

  1. #1
    I have a 4 digit variable.
    How can I get the last 2 digits of a variable and put it in another variable?
     
    ImpulseHorizon, Apr 27, 2008 IP
  2. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What language are you programming in?

    In PHP substr would do it.

    <?
    $checkme = substr("last_two", -2);
    $new_var=$checkme;
    echo $new_var;
    ?>

    Would return wo

    You
     
    LittleJonSupportSite, Apr 27, 2008 IP
  3. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Gonzo4u, Apr 27, 2008 IP