Answer the question
In order to leave comments, you need to log in
How to remove data from php array?
The API returns this:
{"return":[{"usd":0.73644968}{"xfc":0}]}
how do i get usd using php?
Answer the question
In order to leave comments, you need to log in
<?php
$api = '{"return":[{"usd":0.73644968},{"btc":0.01526533},{"66":0},{"aero":0},{"ar":0},{"asce":0},{"bank":0},{"blz":0},{"bltr":0},{"bnc":0},{"bpc":0},{"brit":0},{"bst":0},{"btcs":0},{"btq":0},{"cam":0},{"cann":0},{"ccn":0},{"cesc":0},{"cfc2":0},{"cln":0},{"cnl":0},{"coin":0},{"cool":0},{"cinni":0},{"crt":0},{"cso":0},{"doge":0},{"drk":0},{"duck":0},{"dvc":0},{"elite":0},{"enrg":0},{"fire":0},{"food":0},{"frsh":0},{"fry":0},{"fsc":0},{"ftc":0},{"ghc":0},{"gly":0},{"god":0},{"grc":0},{"hodor":0},{"html":0},{"icg":0},{"isis":0},{"isr":0},{"lgbt":0},{"lit":0},{"lize":0},{"ltc":0},{"lts":0},{"max":0},{"min":0},{"mj":0},{"mona":0},{"moto":0},{"mtc":0},{"neb":0},{"nhc":0},{"nmc":0},{"note":0},{"nud":0},{"pcc":0},{"pes":0},{"plcn":0},{"pop":0},{"pos":0},{"pro":0},{"pseud":0},{"pyra":0},{"qb":0},{"rce":0},{"rox":0},{"rsn":0},{"rvc":0},{"sbc":0},{"sdc":0},{"spata":0},{"spcc":0},{"spn":0},{"start":0},{"stc":0},{"super":0},{"svc":0},{"tech":0},{"thank":0},{"tor":0},{"trk":0},{"trust":0},{"uro":0},{"via":0},{"vrc":0},{"vtc":0},{"water":0},{"was":0},{"web":0},{"xan":0},{"xbd":0},{"xbl":0},{"xgr":0},{"yacc":0},{"x15c":0},{"xfc":0}]}';
$data = json_decode($api, true);
// переводим курсы валют в удобный нам формат
$currencyRates = array_reduce($data['return'], function ($rates, $rate) {
return array_merge($rates, $rate);
}, []);
var_dump($currencyRates);
$usd = $currencyRates['usd'];
$a= json_decode( '{"return":[{"usd":0.73644968}{"xfc":0}]}' );
echo $a['return']['usd'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question