vendredi 26 mai 2017

Looping N size nested array

I have nested array and I need to loop second level deep nested array and do some match.

Loop friends array and compare reqs_status where user_id is the loggedin user ($id).

Json array shown below:

[  
   {  
      "id":8,
      "firstname":"Lauren",
      "lastname":"Lambie",
      "email":"lal30@org.uk",
      "role":1,
      "photo":"uploads\/5.jpg",
      "bio":"Surfer, follower of Christ, band member and Swiss design-head.",
      "friends":[  
         {  
            "id":8,
            "user_id":9,
            "friend_id":8,
            "reqs_status":2,
            "created_at":null,
            "updated_at":null
         }
      ]
   },
   {  
      "id":23,
      "firstname":"Jar",
      "lastname":"Morrison",
      "email":"jm93@org.uk",
      "role":1,
      "photo":"uploads\/20.jpg",
      "bio":"Operating at the crossroads of beauty and intellectual purity.",
      "friends":[  
         {  
            "id":21,
            "user_id":22,
            "friend_id":23,
            "reqs_status":2,
            "created_at":null,
            "updated_at":null
         },
         {  
            "id":28,
            "user_id":21,
            "friend_id":23,
            "reqs_status":0,
            "created_at":null,
            "updated_at":null
         }
      ]
   }
]



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2r4Uboc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire