Google Stock API からいくつかのデータを抽出しようとしています。だからそれを抽出しようとしているだけです。
$t=time();
echo(date("H:i",$t))."<br><br>";
$xml="http://www.google.com/ig/api?stock=KNEBV&stock=FUM1V";
$xml = json_decode(json_encode((array) simplexml_load_file($xml)), 1);
echo '<pre>';
print_r($xml);
echo '</pre>';
?>
これにより、以下の出力が得られます。しかし、私は価値をつかむことができないようです。私はデータに夢中で、どちらから始めればよいかわかりません。
$ xml- > finance[0]->symbolで" FUM1V " が返され、$xml-> finance[1]->symbolでKNEBVが返されると思いますが、どんな組み合わせを試しても空白が表示され続けます。わかりました、それは悪い例かもしれませんが、翻訳で失われます.
「ループ」して各シンボルといくつかの値を出力する方法についてのアイデアはありますか?
Array
(
[@attributes] => Array
(
[version] => 1
)
[finance] => Array
(
[0] => Array
(
[@attributes] => Array
(
[module_id] => 0
[tab_id] => 0
[mobile_row] => 0
[mobile_zipped] => 1
[row] => 0
[section] => 0
)
[symbol] => Array
(
[@attributes] => Array
(
[data] => FUM1V
)
)
[pretty_symbol] => Array
(
[@attributes] => Array
(
[data] => FUM1V
)
)
[symbol_lookup_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=FUM1V
)
)
[company] => Array
(
[@attributes] => Array
(
[data] => Fortum Oyj
)
)
[exchange] => Array
(
[@attributes] => Array
(
[data] => HEL
)
)
[exchange_timezone] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_utc_offset] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_closing] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[divisor] => Array
(
[@attributes] => Array
(
[data] => 2
)
)
[currency] => Array
(
[@attributes] => Array
(
[data] => EUR
)
)
[last] => Array
(
[@attributes] => Array
(
[data] => 14.68
)
)
[high] => Array
(
[@attributes] => Array
(
[data] => 14.77
)
)
[low] => Array
(
[@attributes] => Array
(
[data] => 14.59
)
)
[volume] => Array
(
[@attributes] => Array
(
[data] => 1216170
)
)
[avg_volume] => Array
(
[@attributes] => Array
(
[data] => 1607
)
)
[market_cap] => Array
(
[@attributes] => Array
(
[data] => 13041.22
)
)
[open] => Array
(
[@attributes] => Array
(
[data] => 14.60
)
)
[y_close] => Array
(
[@attributes] => Array
(
[data] => 14.59
)
)
[change] => Array
(
[@attributes] => Array
(
[data] => +0.09
)
)
[perc_change] => Array
(
[@attributes] => Array
(
[data] => 0.62
)
)
[delay] => Array
(
[@attributes] => Array
(
[data] => 0
)
)
[trade_timestamp] => Array
(
[@attributes] => Array
(
[data] => 5 hours ago
)
)
[trade_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[trade_time_utc] => Array
(
[@attributes] => Array
(
[data] => 152953
)
)
[current_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[current_time_utc] => Array
(
[@attributes] => Array
(
[data] => 212211
)
)
[symbol_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=FUM1V
)
)
[chart_url] => Array
(
[@attributes] => Array
(
[data] => /finance/chart?q=HEL:FUM1V&tlf=12
)
)
[disclaimer_url] => Array
(
[@attributes] => Array
(
[data] => /help/stock_disclaimer.html
)
)
[ecn_url] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[daylight_savings] => Array
(
[@attributes] => Array
(
[data] => true
)
)
)
[1] => Array
(
[@attributes] => Array
(
[module_id] => 0
[tab_id] => 0
[mobile_row] => 0
[mobile_zipped] => 1
[row] => 0
[section] => 0
)
[symbol] => Array
(
[@attributes] => Array
(
[data] => KNEBV
)
)
[pretty_symbol] => Array
(
[@attributes] => Array
(
[data] => KNEBV
)
)
[symbol_lookup_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=KNEBV
)
)
[company] => Array
(
[@attributes] => Array
(
[data] => KONE Corporation
)
)
[exchange] => Array
(
[@attributes] => Array
(
[data] => HEL
)
)
[exchange_timezone] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_utc_offset] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_closing] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[divisor] => Array
(
[@attributes] => Array
(
[data] => 2
)
)
[currency] => Array
(
[@attributes] => Array
(
[data] => EUR
)
)
[last] => Array
(
[@attributes] => Array
(
[data] => 65.95
)
)
[high] => Array
(
[@attributes] => Array
(
[data] => 67.00
)
)
[low] => Array
(
[@attributes] => Array
(
[data] => 65.95
)
)
[volume] => Array
(
[@attributes] => Array
(
[data] => 249502
)
)
[avg_volume] => Array
(
[@attributes] => Array
(
[data] => 303
)
)
[market_cap] => Array
(
[@attributes] => Array
(
[data] => 16911.31
)
)
[open] => Array
(
[@attributes] => Array
(
[data] => 66.10
)
)
[y_close] => Array
(
[@attributes] => Array
(
[data] => 66.05
)
)
[change] => Array
(
[@attributes] => Array
(
[data] => -0.10
)
)
[perc_change] => Array
(
[@attributes] => Array
(
[data] => -0.15
)
)
[delay] => Array
(
[@attributes] => Array
(
[data] => 0
)
)
[trade_timestamp] => Array
(
[@attributes] => Array
(
[data] => 5 hours ago
)
)
[trade_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[trade_time_utc] => Array
(
[@attributes] => Array
(
[data] => 152952
)
)
[current_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[current_time_utc] => Array
(
[@attributes] => Array
(
[data] => 212211
)
)
[symbol_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=KNEBV
)
)
[chart_url] => Array
(
[@attributes] => Array
(
[data] => /finance/chart?q=HEL:KNEBV&tlf=12
)
)
[disclaimer_url] => Array
(
[@attributes] => Array
(
[data] => /help/stock_disclaimer.html
)
)
[ecn_url] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[daylight_savings] => Array
(
[@attributes] => Array
(
[data] => true
)
)
)
)
)