Parsing JSON data from a remote server

JVarhol picture JVarhol · Jan 9, 2014 · Viewed 16.4k times · Source

I was wondering if there was any way to make a Parser in PHP in which gets the values from this site https://btc-e.com/api/2/btc_usd/ticker and sets them as variables in php code?

I have looked at php parsers a bit and the only thing I found was parsers that echo all the information on a website.

Answer

Hanky Panky picture Hanky Panky · Jan 9, 2014

Since that URL returns a JSON response:

<?php

$content=file_get_contents("https://btc-e.com/api/2/btc_usd/ticker");
$data=json_decode($content);
//do whatever with $data now
?>