お世話になっております。
phpにて外国為替情報を取得したく、file_get_contents()を用い、以下のようなデータが取得出来ています。
{"quotes":[{"high":"1.9235","open":"1.9235","bid":"1.9235","currencyPairCode":"GBPNZD","ask":"1.9336","low":"1.9235"},{"high":"84.73","open":"84.73","bid":"84.73","currencyPairCode":"CADJPY","ask":"84.85","low":"84.73"},{"high":"1.7676","open":"1.7676","bid":"1.7676","currencyPairCode":"GBPAUD","ask":"1.7730","low":"1.7676"},{"high":"82.59","open":"82.59","bid":"82.59","currencyPairCode":"AUDJPY","ask":"82.81","low":"82.59"},{"high":"1.0869","open":"1.0869","bid":"1.0869","currencyPairCode":"AUDNZD","ask":"1.0913","low":"1.0869"},{"high":"1.5395","open":"1.5395","bid":"1.5395","currencyPairCode":"EURCAD","ask":"1.5427","low":"1.5395"},{"high":"1.1720","open":"1.1720","bid":"1.1720","currencyPairCode":"EURUSD","ask":"1.1729","low":"1.1720"},{"high":"75.77","open":"75.77","bid":"75.77","currencyPairCode":"NZDJPY","ask":"76.00","low":"75.77"},{"high":"1.3133","open":"1.3133","bid":"1.3133","currencyPairCode":"USDCAD","ask":"1.3153","low":"1.3133"},{"high":"0.8917","open":"0.8917","bid":"0.8917","currencyPairCode":"EURGBP","ask":"0.8932","low":"0.8917"},{"high":"1.3125","open":"1.3125","bid":"1.3125","currencyPairCode":"GBPUSD","ask":"1.3148","low":"1.3125"},{"high":"8.241","open":"8.241","bid":"8.241","currencyPairCode":"ZARJPY","ask":"8.391","low":"8.241"},{"high":"1.1625","open":"1.1625","bid":"1.1625","currencyPairCode":"EURCHF","ask":"1.1649","low":"1.1625"},{"high":"112.11","open":"112.11","bid":"112.11","currencyPairCode":"CHFJPY","ask":"112.37","low":"112.11"},{"high":"0.7414","open":"0.7414","bid":"0.7414","currencyPairCode":"AUDUSD","ask":"0.7432","low":"0.7414"},{"high":"0.9916","open":"0.9916","bid":"0.9916","currencyPairCode":"USDCHF","ask":"0.9936","low":"0.9916"},{"high":"130.57","open":"130.57","bid":"130.57","currencyPairCode":"EURJPY","ask":"130.73","low":"130.57"},{"high":"1.3015","open":"1.3015","bid":"1.3015","currencyPairCode":"GBPCHF","ask":"1.3063","low":"1.3015"},{"high":"1.7178","open":"1.7178","bid":"1.7178","currencyPairCode":"EURNZD","ask":"1.7249","low":"1.7178"},{"high":"0.6801","open":"0.6801","bid":"0.6801","currencyPairCode":"NZDUSD","ask":"0.6821","low":"0.6801"},{"high":"111.39","open":"111.39","bid":"111.39","currencyPairCode":"USDJPY","ask":"111.46","low":"111.39"}]}
このデータからUSDJPYのhigh、open、bid、ask、lowそれぞれの値を取得したいと考えていますが、その取得方法が分かりません。
json_decode()を使うことで以下のようなデータ形式に整えるまで至ったのですが適切な取得(検索)が出来ずにいる次第です。
stdClass Object ( [quotes] => Array ( [0] => stdClass Object ( [high] => 1.9235 [open] => 1.9235 [bid] => 1.9235 [currencyPairCode] => GBPNZD [ask] => 1.9336 [low] => 1.9235 ) [1] => stdClass Object ( [high] => 84.73 [open] => 84.73 [bid] => 84.73 [currencyPairCode] => CADJPY [ask] => 84.85 [low] => 84.73 ) [2] => stdClass Object ( [high] => 1.7676 [open] => 1.7676 [bid] => 1.7676 [currencyPairCode] => GBPAUD [ask] => 1.7730 [low] => 1.7676 ) [3] => stdClass Object ( [high] => 82.59 [open] => 82.59 [bid] => 82.59 [currencyPairCode] => AUDJPY [ask] => 82.81 [low] => 82.59 ) [4] => stdClass Object ( [high] => 1.0869 [open] => 1.0869 [bid] => 1.0869 [currencyPairCode] => AUDNZD [ask] => 1.0913 [low] => 1.0869 ) [5] => stdClass Object ( [high] => 1.5395 [open] => 1.5395 [bid] => 1.5395 [currencyPairCode] => EURCAD [ask] => 1.5427 [low] => 1.5395 ) [6] => stdClass Object ( [high] => 1.1720 [open] => 1.1720 [bid] => 1.1720 [currencyPairCode] => EURUSD [ask] => 1.1729 [low] => 1.1720 ) [7] => stdClass Object ( [high] => 75.77 [open] => 75.77 [bid] => 75.77 [currencyPairCode] => NZDJPY [ask] => 76.00 [low] => 75.77 ) [8] => stdClass Object ( [high] => 1.3133 [open] => 1.3133 [bid] => 1.3133 [currencyPairCode] => USDCAD [ask] => 1.3153 [low] => 1.3133 ) [9] => stdClass Object ( [high] => 0.8917 [open] => 0.8917 [bid] => 0.8917 [currencyPairCode] => EURGBP [ask] => 0.8932 [low] => 0.8917 ) [10] => stdClass Object ( [high] => 1.3125 [open] => 1.3125 [bid] => 1.3125 [currencyPairCode] => GBPUSD [ask] => 1.3148 [low] => 1.3125 ) [11] => stdClass Object ( [high] => 8.241 [open] => 8.241 [bid] => 8.241 [currencyPairCode] => ZARJPY [ask] => 8.391 [low] => 8.241 ) [12] => stdClass Object ( [high] => 1.1625 [open] => 1.1625 [bid] => 1.1625 [currencyPairCode] => EURCHF [ask] => 1.1649 [low] => 1.1625 ) [13] => stdClass Object ( [high] => 112.11 [open] => 112.11 [bid] => 112.11 [currencyPairCode] => CHFJPY [ask] => 112.37 [low] => 112.11 ) [14] => stdClass Object ( [high] => 0.7414 [open] => 0.7414 [bid] => 0.7414 [currencyPairCode] => AUDUSD [ask] => 0.7432 [low] => 0.7414 ) [15] => stdClass Object ( [high] => 0.9916 [open] => 0.9916 [bid] => 0.9916 [currencyPairCode] => USDCHF [ask] => 0.9936 [low] => 0.9916 ) [16] => stdClass Object ( [high] => 130.57 [open] => 130.57 [bid] => 130.57 [currencyPairCode] => EURJPY [ask] => 130.73 [low] => 130.57 ) [17] => stdClass Object ( [high] => 1.3015 [open] => 1.3015 [bid] => 1.3015 [currencyPairCode] => GBPCHF [ask] => 1.3063 [low] => 1.3015 ) [18] => stdClass Object ( [high] => 1.7178 [open] => 1.7178 [bid] => 1.7178 [currencyPairCode] => EURNZD [ask] => 1.7249 [low] => 1.7178 ) [19] => stdClass Object ( [high] => 0.6801 [open] => 0.6801 [bid] => 0.6801 [currencyPairCode] => NZDUSD [ask] => 0.6821 [low] => 0.6801 ) [20] => stdClass Object ( [high] => 111.39 [open] => 111.39 [bid] => 111.39 [currencyPairCode] => USDJPY [ask] => 111.46 [low] => 111.39 ) ) )
お忙しい中恐縮ですが、アドバイスのほど頂戴出来れば幸いです。
よろしくお願いいたします。
「stdClass Object」って型が出ているので幾らでも調べようがあると思いますが。
回答4件
あなたの回答
tips
プレビュー