1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2017
    Rep Power

    Question getting a percentage and adding it to content

    im working on a json from this site. https://btc-e.com/api/3/ticker/btc_usd
    im trying to get the "last" key and
    im trying to echo my own premiunm exchange rate.by getting 10% of the last key and add it up to the last key
    my codes was like this.
    $url = "https://btc-e.com/api/3/ticker/btc_usd";
    $fileGet = file_get_contents($url);
    $json = json_decode($fileGet, TRUE);
    $json = $json["ticker"]["last"];
    $premium = 10; //in percentage
    $premium = $premium / 100;
    $dollar_amount = $premium * $json;
    $customer_price = $json + $dollar_amount;
    echo $customer_price;

    there was no error indicated.but it just printed "0" on the screen.
    please help. i dont know where something does wrong.

    but everything work fine to line 4 $json=$json["ticker"]["last"]; because it print the correct last ticker on the browser.
    something may have when wrong after that.please help
  2. #2
  3. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    As I told you somewhere else, there is no ["ticker"] in the JSON.

    Comments on this post

    • charlion agrees : thank you so much.. that was the problem/now it works

IMN logo majestic logo threadwatch logo seochat tools logo