如何使用php访问JSON内容中的特定字段? [英] How to access particular fields from JSON content by using php?
本文介绍了如何使用php访问JSON内容中的特定字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过使用php获取Json中不同字段的值
i want to get the values of different fields in Json by using php
推荐答案
json_decode($ string)将返回一个对象,您可以从中获取分配的值.
json_decode($string) will return an object from which you can get the values you assigned.
例如:
$myObject = new MyObject();
$myObject -> att1 = 5;
$string = json_encode($myObject);
//here's how you get the value:
$myJsonDecodedObject = json_decode($string);
$value = $myJsonDecodedObject -> att1;
这篇关于如何使用php访问JSON内容中的特定字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文