Answer the question
In order to leave comments, you need to log in
How to display price from json in php?
Good afternoon. There is this code:
<?php if(in_category(4)) :
$tick = file_get_contents('https://api.coinmarketcap.com/v1/ticker/bitcoin?convert=RUB');
$data = json_decode($tick, TRUE);
$price = $data[0]["price_rub"];
echo "<div>Текущая цена: ".$price." РУБ</div>";
?>
<?php endif; ?>
Answer the question
In order to leave comments, you need to log in
$price = $data["data"]["quotes"]["RUB"]["price"];
echo "<div>Текущая цена: ".$price." РУБ</div>";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question