I receive jsons in this format:
{"106371527":[33,22,11,2],"10003989":[3,2,11,3]}
note: 106371527,10003989 users ids
when I use json_decode(), still can't access data because the object keys is int,
how to fix this?
thanks,
I receive jsons in this format:
{"106371527":[33,22,11,2],"10003989":[3,2,11,3]}
note: 106371527,10003989 users ids
when I use json_decode(), still can't access data because the object keys is int,
how to fix this?
thanks,
I just found the answer, use:
json_decode($json, true);
to return array rather than object,
http://php.net/manual/en/function.json-decode.php
thanks,
You should also be able to access the property by wrapping it in {}
:
$json = '{"106371527":[33,22,11,2],"10003989":[3,2,11,3]}';
$object = json_decode($json);
print_r($object->{106371527});