So, I am pulling out a custom JSON tweeter via PHP. I would like to decode it into an associative array, or at least a more convenient way, rather than a string, so that I can maneuver through it.
I read like crazy about json_decode, but it seems to me that when I use it, before and after, the contents of the file still show up as one long line. Can someone help me figure out what I'm doing wrong?
$url = "http://twitter.com/status/user_timeline/" . $username . ".json?count=" . $count . "&callback=?";
// $url becomes "http://twitter.com/status/user_timeline/steph_Rose.json?count=5&callback=?";
$contents = file_get_contents($url);
$results = json_decode($contents, true);
echo "<pre>";
print_r($results);
echo "</pre>";
echo gettype($results); // this returns string
source
share