我有一个json对象数组。我想读这个值。如何使用PHP读取值。 我的json对象数组
[{"employeeId":"ioc-nugegoda","employeeEmail":"lankaioc@lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nugeqqq","employeeEmail":"lankaioc@lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nusqq","employeeEmail":"lankaioc@lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"}]
答案 0 :(得分:1)
$jsonObject = json_decode('{"employeeId":"ioc-nugegoda","employeeEmail":"lankaioc@lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nugeqqq","employeeEmail":"lankaioc@lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nusqq","employeeEmail":"lankaioc@lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"}');
您可以找到here。之后,您可以通过其键访问json对象的所有值:
echo $jsonObject["employeeId"];
//Should return: ioc-nugegoda
如果你的JsonObject周围有一个数组,你首先需要访问该对象..这看起来像:
echo $jsonObject[0]["employeeId"];