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.

how to do decimal point to be 0?

Discussion in 'PHP' started by Adulu, Feb 14, 2011.

  1. #1
    There's a question.
    if don't need decimal point, how to do?


    $num="5.8";
    $num=round ($num,0);
    echo "$num";
    the result is 6

    but i'd like it to be 5.:confused:

    i need your help.
    thank you
     
    Adulu, Feb 14, 2011 IP
  2. seoelk.com

    seoelk.com Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try floor() function
     
    seoelk.com, Feb 14, 2011 IP
    Adulu likes this.
  3. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it can work.
    thank you so much
     
    Adulu, Feb 14, 2011 IP
  4. JohnRazmus

    JohnRazmus Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Another handy one is number_format( $number, $numberOfDecimalPlacesToShow );

    So number_format( "6.4", 2 ) would be 6.40. The fun part about this function also is it can do currencies (default to US), so:

    number_format( "4346.1246", 2 ) would be 4,346.12
     
    JohnRazmus, Feb 14, 2011 IP