0

Hullo :3
I'm currently dabbling with the Twitter API and would like to decode a JSON response similar to this: https://dev.twitter.com/docs/api/1.1/get/users/lookup (bottom of page).

I'm quite a novice with PHP (14 y/o) so please don't be harsh with the dislikes. I have scoured the Internet before asking this question. There are one or two relevant tutorials but they just confuse me even more. So please, don't be harsh, and explain how I'd achieve this as easily as possible so I can get my head around it. :)

I know you can't decode this type of response easily because it has two parts, one for each user requested.

Thank you in advance and have a great day.

728883902
  • 507
  • 1
  • 4
  • 21
  • This should solve your problem http://stackoverflow.com/questions/2560096/how-to-decode-a-json-string-with-several-objects-in-php – Borstenhorst Jul 27 '13 at 20:32

2 Answers2

1

All you need is json_decode.

The result will be an array with your user objects.

Tobias Golbs
  • 4,586
  • 3
  • 28
  • 49
0

Just use json_decode. After that you can use foreach to get the single objects.

$allobjects = json_decode($json);
foreach ($allobjects as $singleobject) {
     //handle the single objects    
}
Borstenhorst
  • 1,716
  • 2
  • 13
  • 11