URL이 http://btcrate.com/convert?from=btc&to=usd&exch=mtgox&conv=xe&amount=0.01
인 {"converted": "1.300000300"}
입니다. PHP 값으로 변환 된 값을 얻고 싶습니다. 따라서 $usd = 1.300000300;
.URL에서 배열 값 가져 오기
나는 다음을 시도했지만 단지 변환 된 값을 원하지만 전체 문자열 만 출력합니다. 배열을 사용하는 당신은 JSON
을 디코딩 한 후 간단하게 converted
$data = file_get_contents("http://btcrate.com/convert?from=btc&to=usd&exch=mtgox&conv=xe&amount=0.01");
$obj = json_decode($data);
$converted = $obj->{'converted'};
echo $converted;
Learn more about using JSON in PHP here