1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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,989
    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,220
    Likes Received:
    778
    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,486
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    230
    #4
    Little but very usefulll help. Thanks.
     
    YIAM, Oct 27, 2006 IP
  5. helleborine

    helleborine Well-Known Member

    Messages:
    909
    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