fork(1) download
  1. <?php
  2.  
  3. $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}]}';
  4. $data = json_decode($api, true);
  5.  
  6. // переводим курсы валют в удобный нам формат
  7. $currencyRates = array_reduce($data['return'], function ($rates, $rate) {
  8. return array_merge($rates, $rate);
  9. }, []);
  10.  
  11. var_dump($currencyRates);
  12.  
  13. $usd = $currencyRates;
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
array(105) {
  ["usd"]=>
  float(0.73644968)
  ["btc"]=>
  float(0.01526533)
  [0]=>
  int(0)
  ["aero"]=>
  int(0)
  ["ar"]=>
  int(0)
  ["asce"]=>
  int(0)
  ["bank"]=>
  int(0)
  ["blz"]=>
  int(0)
  ["bltr"]=>
  int(0)
  ["bnc"]=>
  int(0)
  ["bpc"]=>
  int(0)
  ["brit"]=>
  int(0)
  ["bst"]=>
  int(0)
  ["btcs"]=>
  int(0)
  ["btq"]=>
  int(0)
  ["cam"]=>
  int(0)
  ["cann"]=>
  int(0)
  ["ccn"]=>
  int(0)
  ["cesc"]=>
  int(0)
  ["cfc2"]=>
  int(0)
  ["cln"]=>
  int(0)
  ["cnl"]=>
  int(0)
  ["coin"]=>
  int(0)
  ["cool"]=>
  int(0)
  ["cinni"]=>
  int(0)
  ["crt"]=>
  int(0)
  ["cso"]=>
  int(0)
  ["doge"]=>
  int(0)
  ["drk"]=>
  int(0)
  ["duck"]=>
  int(0)
  ["dvc"]=>
  int(0)
  ["elite"]=>
  int(0)
  ["enrg"]=>
  int(0)
  ["fire"]=>
  int(0)
  ["food"]=>
  int(0)
  ["frsh"]=>
  int(0)
  ["fry"]=>
  int(0)
  ["fsc"]=>
  int(0)
  ["ftc"]=>
  int(0)
  ["ghc"]=>
  int(0)
  ["gly"]=>
  int(0)
  ["god"]=>
  int(0)
  ["grc"]=>
  int(0)
  ["hodor"]=>
  int(0)
  ["html"]=>
  int(0)
  ["icg"]=>
  int(0)
  ["isis"]=>
  int(0)
  ["isr"]=>
  int(0)
  ["lgbt"]=>
  int(0)
  ["lit"]=>
  int(0)
  ["lize"]=>
  int(0)
  ["ltc"]=>
  int(0)
  ["lts"]=>
  int(0)
  ["max"]=>
  int(0)
  ["min"]=>
  int(0)
  ["mj"]=>
  int(0)
  ["mona"]=>
  int(0)
  ["moto"]=>
  int(0)
  ["mtc"]=>
  int(0)
  ["neb"]=>
  int(0)
  ["nhc"]=>
  int(0)
  ["nmc"]=>
  int(0)
  ["note"]=>
  int(0)
  ["nud"]=>
  int(0)
  ["pcc"]=>
  int(0)
  ["pes"]=>
  int(0)
  ["plcn"]=>
  int(0)
  ["pop"]=>
  int(0)
  ["pos"]=>
  int(0)
  ["pro"]=>
  int(0)
  ["pseud"]=>
  int(0)
  ["pyra"]=>
  int(0)
  ["qb"]=>
  int(0)
  ["rce"]=>
  int(0)
  ["rox"]=>
  int(0)
  ["rsn"]=>
  int(0)
  ["rvc"]=>
  int(0)
  ["sbc"]=>
  int(0)
  ["sdc"]=>
  int(0)
  ["spata"]=>
  int(0)
  ["spcc"]=>
  int(0)
  ["spn"]=>
  int(0)
  ["start"]=>
  int(0)
  ["stc"]=>
  int(0)
  ["super"]=>
  int(0)
  ["svc"]=>
  int(0)
  ["tech"]=>
  int(0)
  ["thank"]=>
  int(0)
  ["tor"]=>
  int(0)
  ["trk"]=>
  int(0)
  ["trust"]=>
  int(0)
  ["uro"]=>
  int(0)
  ["via"]=>
  int(0)
  ["vrc"]=>
  int(0)
  ["vtc"]=>
  int(0)
  ["water"]=>
  int(0)
  ["was"]=>
  int(0)
  ["web"]=>
  int(0)
  ["xan"]=>
  int(0)
  ["xbd"]=>
  int(0)
  ["xbl"]=>
  int(0)
  ["xgr"]=>
  int(0)
  ["yacc"]=>
  int(0)
  ["x15c"]=>
  int(0)
  ["xfc"]=>
  int(0)
}