Your Ad Here

Posted By

jrobinsonc on 04/05/10


Tagged

json


Versions (?)

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":"foo@foobar.com","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.