1
My code is抽出データ
$url = "URL";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 1
));
$result = curl_exec($curl);
var_dump($result);
$json = json_decode($result);
print_r($json);
curl_close($curl);
The response from var_dump($result) is -
string(1866) "{"status":true,"result":[{"time":"2016-11-15T19:20:27.000Z"},{"time":"2016-11-15T19:18:15.000Z"},{"time":"2016-11-15T19:15:03.000Z"},
The response I get from print_r($json) is -
stdClass Object
(
[status] => 1
[result] => Array
(
[0] => stdClass Object
(
[time] => 2016-11-15T19:20:27.000Z
)
[1] => stdClass Object
(
[time] => 2016-11-15T19:18:15.000Z
)
[2] => stdClass Object
(
[time] => 2016-11-15T19:15:03.000Z
)
私はいくつかの変数に時間の値を必要としています。私は変数に応答から時間の値を得るのですか
Something I have done in Javscript is -
var response = JSON.parse(xmlHttpSerie.responseText);
response.forEach(function(items)
{
currentTime = items.time;
}
は誰も教えてもらえますか?
私はこのエラーを取得 - 'PHP致命的なエラー:/var/www/html/fileName.php上での配列としてのタイプはstdClassのオブジェクトを使用することはできませんline 45' – SMG
@SMG: '' echo 'の直前に '$ json = json_decode($ result、true);という行がありますか? –
はい、私は走ったコードでコメントを解除しました! – SMG