0

代码:

{"high": "145.00", "last": "143.92", "timestamp": "1382049657", "bid": "143.81", "volume": "17883.09636191", "low": "135.00", "ask": "143.92"}

我如何从这张票中获得“询问”价值?

我使用此代码来获取它:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.bitstamp.net/api/ticker/');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$getit= curl_exec($ch);
curl_close($ch);

echo $getit;
4

1 回答 1

2

网站响应采用JSON格式,您必须首先使用json_decode将其解码为数组。

$ticket = json_decode($getit, true);

echo $ticket['ask'];
于 2013-10-17T22:46:58.237 回答