如何以PHP形式获取JSON数据记录

时间:2019-07-12 10:56:25

标签: php json

我想以php形式获取json数据。我在下面使用了此代码,但尽管该字段有记录,但显示为空记录。如何获取值请指导。谢谢

 $json = '{"records":

 {"id":1769,"categoryid":1,"adminid":0,"clientid":207,"userid":0,
  "manufacturerid":0,"modelid":24,"supplierid":0,"statusid":1,
  "purchase_date":"","warranty_months":0,"tag":"SN -485",
  "name":"EASY coffee machine","serial":"484","notes":"LIVE PANTRY",
  "locationid":46,"purchase_order":"","value":"",
  "condition":"","removal_date":"","Manufacture_serial_no":"",
  "Barcode":"6091234567890","barcode_added_by":"","flag":1}
  }';

// Converts it into a PHP object
$data = json_decode($json);

var_dump($data->record->id);

1 个答案:

答案 0 :(得分:1)

   Use This : echo $data->records->id;