php - Why is print_r still printing out a Json object? -
i broke code many steps possible try figure out doing.
$addsdata='http://football.myfantasyleague.com/2013/exporttype=topadds&l=&w=&json=1'; $addsdata = json_encode(file_get_contents($addsdata)); $addersdata = file_put_contents("addsdata.txt", $addsdata); $getadds = file_get_contents("addsdata.txt"); $topaddsdata = json_decode($getadds, true); echo "<pre>"; print_r($topaddsdata); echo "</pre>";
and here result getting...
"version":"1.0","topadds":{"week":"1","player":[{"percent":"25.95","id":"9705"},{"percent":"23.92","id":"10372"},{"percent":"23.72","id":"11440"},{"percent":"23.43","id":"11259"},{"percent":"20.29","id":"9079"},{"percent":"17.06","id":"10048"},{"percent":"16.93","id":"11227"},{"percent":"14.66","id":"10500"},{"percent":"14.10","id":"9964"},{"percent":"13.90","id":"10862"},{"percent":"13.80","id":"9834"},{"percent":"13.55","id":"10355"},{"percent":"13.29","id":"10961"},{"percent":"13.27","id":"9437"},{"percent":"11.87","id":"9912"}, }
my understanding reading manual should associative array because passing in true parameter. missing here?
the url querying returning json string (this can seen url parameters), encoding again. result, decoding afterwards still leaves json string.
for example, if url's contents (and initial value of $addsdata
) describing object:
{ "foo": "bar" }
then after encoding new value of $addsdata
describing string:
"{ \"foo\": \"bar\" }"
skip json_encode
, things should work fine.
Comments
Post a Comment