Thread: 9.7589 to 9.76

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Johannesburg, South Africa
    Posts
    10
    Rep Power
    0
    Hi,

    There was a posting earlier to print from 9.7589 to 9.76 - but I need something which can make $cost from 9.7589 to 9.76

    I have searched the PHP site to see which command to use but had no luck.

    Regards
    Tont
  2. #2
  3. No Profile Picture
    worshipper of DOT
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Halmstad, Sweden
    Posts
    35
    Rep Power
    15
    look up number_format(), that's probably what you need.

    ------------------
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Linux, the operating system with a clue - Command Line User Environment.[/quote]

    geeee... thanks!

    /closecut
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    Well, to print the variable is easy enough... just use printf(). As for setting
    the variable, you might try this:

    <?php
    $cost = 9.7586;
    $newcost = (float) sprintf("%0.2f",$cost);
    print "$newcost";
    ?>

    $newcost will be equal to 9.76.

    (I tried this locally and it seemed to work alright, send me an e-mail if you have any problems getting it to work.)

    [This message has been edited by cka (edited April 21, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo