Posted By

paulgrenwood on 09/23/09


php parse json

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Parse JSON Data

 / Published in: PHP

With most of the popular web services like Twitter providing their data through APIs, it is always helpful to know how to parse API data which is sent in various formats including JSON, XML etc.

  1. $json_string='{"id":1,"name":"foo","email":"[email protected]","interest":["wordpress","php"]} ';
  2. $obj=json_decode($json_string);
  3. echo $obj->name; //prints foo
  4. echo $obj->interest[1]; //prints php

Report this snippet  

You need to login to post a comment.