PHP JSON 数据解析代码 作者: 字体:[增加减小] 类型:转载

 
PHP解析JSON 数据代码,与大多数流行的 Web 服务如 twitter 、人人网通过开放 API 来提供数据一样,它总是能够知道如何解析 API 数据的各种传送格式,包括 JSON,XML 等等。
 
代码如下:

$json_string='{"id":1,"name":"jb51","email":"admin@jb51.net","interest":["wordpress","php"]} '; 
$obj=json_decode($json_string); 
echo $obj->name; //prints foo 
echo $obj->interest[1]; //prints php