Returning integers

Discussion in 'PHP' started by helleborine, Oct 27, 2006.

  1. #1
    Elementary question from a newbie.

    I'd like the following operation to return an INTEGER value, ie, no decimals:

    <?php if($_POST["submit"])
    {
    $result2 =(($_POST['dheight']/ $_POST['oheight']) *100);
    echo "Multiply the height by: $result2"." %";
    }?> 
    
    Code (markup):
     
    helleborine, Oct 27, 2006 IP
    YIAM likes this.
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    mad4, Oct 27, 2006 IP
    YIAM and helleborine like this.
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Or (int)$result2 but rounding is nicer IMO.
     
    T0PS3O, Oct 27, 2006 IP
    YIAM likes this.
  4. YIAM

    YIAM Notable Member

    Messages:
    2,480
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Little but very usefulll help. Thanks.
     
    YIAM, Oct 27, 2006 IP
  5. helleborine

    helleborine Well-Known Member

    Messages:
    915
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Fab! I used the rounding code and it's working. You guys are great, thanks a million.
     
    helleborine, Oct 27, 2006 IP