eBay API Help

Discussion in 'PHP' started by primster7, Sep 23, 2010.

  1. #1
    I have a script that uses eBay's API and when it displays the prices it drops the last zero in the cents area.

    Example:

    shows: $10.5
    should be: $10.50

    Does anyone know if I can make a change to my script to display all of the numbers?

    I posted the same question on Ebay's forum and I rec'd this answer:

    Add the 0 yourself. If you are using PHP use number_format().

    However, I don't know where to put this code and how to implement it. Also, will it add a 0 to all ending prices correctly. So if it's $9.99 will it show $9.990?

    Any help would be greatly appreciated.
     
    primster7, Sep 23, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    This isnt really an ebay API question, its just using the PHP function which you have been referred to already - Its all detailed in the reference site;

    http://php.net/manual/en/function.number-format.php

    I.E

    <?php
    $yourprice = "15.6";
    $yourprice = number_format($yourprice, 2, '.', '');
    
    print $yourprice;
    ?>
    PHP:
    OUTPUT: 15.60

    It will not add a zero onto the end of decimalized numbers;

    <?php
    $yourprice = "15.60";
    $yourprice = number_format($yourprice, 2, '.','');
    
    print $yourprice;
    ?>
    PHP:
    OUTPUT: 15.60
     
    lukeg32, Sep 24, 2010 IP