mysql - Pulling specific part out of Json string with php -


i'm trying log activity of mtgox using api, deliver standard json string http://data.mtgox.com/api/2/btcusd/money/ticker

now use put neatly organized array

$url = 'http://data.mtgox.com/api/2/btcusd/money/ticker'; $json = file_get_contents($url); $obj = json_decode($json, true); 

but, can't figure out how can pull specific details like, high>value. instead force myself go long way printing out using following loop:

foreach($obj $arr) { if (is_array($arr)) { foreach($arr $arry) { if (is_array($arry)) {             $query_insert_json = "insert currency(currency, currentvalue, highvalue, lowvalue) values('usd', '$arry[value]', '12.987', '9.452')";             $result_insert_json = mysqli_query($dbc, $query_insert_json);             if (!$result_insert_json) {                 echo 'query failed ';             }    echo <<<end <tr> <td align="center">$arry[value]</td> <td align="center">$arry[value_int]</td> <td align="center">$arry[display]</td> <td align="center">$arry[display_short]</td> <td align="center">$arry[currency]</td> </tr> end; 

like this? pull specific details like, high>value

<?php $json=file_get_contents("http://data.mtgox.com/api/2/btcusd/money/ticker"); $json=json_decode($json,true);  echo $json['data']['high']['value']; ?> 

if want find data pull, view source while print_r($json), @ it:

array

every indentation level, looking @ first level, it's data, going second high, lastly it's value.


Comments