开发者

basic JSON pulling data help

开发者 https://www.devze.com 2023-01-02 15:33 出处:网络
New to json data and struggling i guess the answer is real easy but been bugging me for the last hour..

New to json data and struggling i guess the answer is real easy but been bugging me for the last hour..

Sample data

    {
   "data": 
      {
         "userid": "17",
         "dates": {
            "timestame": "1275528578",
                  },
         "username": "harino54",

      }

}

Ok I can pull userid 开发者_如何转开发or username easy enough with

echo "$t->userid" or echo "$t->username "

but how do I pull data from the brackets within ? in this case timestame?

cant seem to figure it out..

any ideas?


It sounds like you are looking for something like this: echo "{$t->dates->timestame}";.

To access data from an object within quotes, you need to surround it with braces.

alternately, you could just say: echo $t->date->timestame; without the quotes.

Are you doing someting like this?

$t = json_decode($jsonString);
echo $t->data->dates->timestame;

or

$t = json_decode($jsonString);
echo "{$t->data->dates->timestame}";


$t -> dates -> timestame
0

精彩评论

暂无评论...
验证码 换一张
取 消