json array in php.
Budget: $10 – $30 CAD
i give 5$ / cad for the resolve.
before my request was
Array ( [0] => stdClass Object ( [symbol] => LINKHIT [ask] => 115.03 [bid] => 65.24
--> LINKHIT have a name, (symbol)
now request is
Array ( [LINKHIT ] => Array ( [ask] => 0.1014101 [bid] => 0.0871149
LINKHIT have no name
can you adapt code please
code is
$response = file_get_contents('MYFILESURL);
$response = json_decode($response,true);
print_r($response);
$str_to_concat = "INSERT INTO `ticker` (`symbol`, `ask`, `bid`, `last`, `low`, `high`, `open`, `volume`, `volumeQuote`, `timestamp`)
VALUES";
foreach($response as $item) {
$symbol=
$str_to_concat = $str_to_concat."('$item->symbol' , '$item->ask', '$item->bid', '$item->last', '$item->low', '$item->high', '$item->open', '$item->volume','$item->volume_quote', '$item->timestamp'),";
}
// We are removing last char from string, because its comma ` , `
$str_to_concat = substr_replace($str_to_concat ,"", -1);
$sqlt = $str_to_concat;
before my request was
Array ( [0] => stdClass Object ( [symbol] => LINKHIT [ask] => 115.03 [bid] => 65.24
--> LINKHIT have a name, (symbol)
now request is
Array ( [LINKHIT ] => Array ( [ask] => 0.1014101 [bid] => 0.0871149
LINKHIT have no name
can you adapt code please
code is
$response = file_get_contents('MYFILESURL);
$response = json_decode($response,true);
print_r($response);
$str_to_concat = "INSERT INTO `ticker` (`symbol`, `ask`, `bid`, `last`, `low`, `high`, `open`, `volume`, `volumeQuote`, `timestamp`)
VALUES";
foreach($response as $item) {
$symbol=
$str_to_concat = $str_to_concat."('$item->symbol' , '$item->ask', '$item->bid', '$item->last', '$item->low', '$item->high', '$item->open', '$item->volume','$item->volume_quote', '$item->timestamp'),";
}
// We are removing last char from string, because its comma ` , `
$str_to_concat = substr_replace($str_to_concat ,"", -1);
$sqlt = $str_to_concat;