PHP decode nested JSON

后端 未结 2 1853
眼角桃花
眼角桃花 2020-12-15 09:37

I\'ve a nested JSON code as (it\'s actually my facebook status updates)

{
   \"data\": [
      {
         \"id\": \"1290561400000000\",
         \"from\": {
         


        
2条回答
  •  不知归路
    2020-12-15 10:22

    Use json_decode():

    $decoded = json_decode($json_string);
    $comments = $decoded->data[0]->comments->data;
    foreach($comments as $comment){
       $name = $comment->from->name;
       $message = $comment->message;
       //do something with it
    }
    

提交回复
热议问题