我正在尝试分析一些政府数据。这是 JSON
{
"results": [
{
"bill_id": "hres311-113",
"bill_type": "hres",
"chamber": "house",
"committee_ids": [
"HSHA"
],
"congress": 113,
"cosponsors_count": 9,
"enacted_as": null,
"history": {
"active": false,
"awaiting_signature": false,
"enacted": false,
"vetoed": false
}
这是php
foreach($key['results'] as $get_key => $value){
$bill_buff .= 'Bill ID: ' . $value['bill_id'] . '<br/>';
$bill_buff .= 'Bill Type: ' . $value['bill_type'] . '<br/>';
$bill_buff .= 'Chamber: ' . $value['chamber'] . '<br/>';
$bill_buff .= 'Committee IDs: ' . $value['committee_ids'] . '<br/>';
$bill_buff .= 'Congress: ' . $value['congress'] . '<br/>';
$bill_buff .= 'Cosponsor Count: ' . $value['cosponsors_count'] . '<br/>';
$bill_buff .= 'Enacted As: ' . $value['enacted_as'] . '<br/>';
$bill_buff .= 'History: {' . '<br/>';
$history = $value['history'];
$bill_buff .= 'Active: ' . $history['active'] . '<br/>';
$bill_buff .= 'Awaiting Signature: ' . $history['awaiting_signature'] . '<br/>';
$bill_buff .= 'Enacted: ' . $history['enacted'] . '<br/>';
$bill_buff .= 'Vetoed: ' . $history['vetoed'] . '}<br/>';
}
它不会显示 History{Active, Awaiting Signature, Enacted, or Vetoed}。我试过做$value['history']['active']
,以及创建一个变量来捕获信息,然后使用它$catch['active']
但仍然无法得到结果。
这已经让我烦恼了一个多星期,我已经看了足够长的时间来决定我需要寻求帮助。任何人都可以帮助我吗?
PS我也 print_r($history) 去给我看:
数组([活动] => [awaiting_signature] => [制定] => [否决] =>)