Answer the question
In order to leave comments, you need to log in
BITCOIN rate parser - RUB / JSON - PHP. How to make the code work?
I want to pull the 'price' parameter from JSON into the $price variable
There is a code:
<?php
$data = json_decode(file_get_contents("https://api.cryptonator.com/api/ticker/btc-rub"));
$price = $data->objects[0]->price;
echo $price;
?>
Answer the question
In order to leave comments, you need to log in
$price = $data->ticker->price;
just do var_dump($data) to see what we need to "pull"
object(stdClass)#2 (4) {
["ticker"]=>
object(stdClass)#1 (5) {
["base"]=>
string(3) "BTC"
["target"]=>
string(3) "RUR"
["price"]=>
string(15) "475260.76937314"
["volume"]=>
string(13) "1206.63030836"
["change"]=>
string(10) "3.44370048"
}
["timestamp"]=>
int(1521061861)
["success"]=>
bool(true)
["error"]=>
string(0) ""
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question