There must be something obvious I'm doing wrong here, but I've spent hours trying to figure it out and it makes no sense.
<?php
date_default_timezone_set('America/New_York');
$json = file_get_contents('https://www.govtrack.us/api/v2/vote/?congress=114&chamber=house&session=2015&order_by=-created');
$obj = json_decode( $json,true);
$bills = $obj['objects'];
foreach($bills as $b){
print_r($b);
print_r($b['category']);
print_r($b['title']); ///wtf.
}
?>
The array returned by the json request has indices for both category and title, but it returns NULL for title. Several other elements from the json array return NULL for some reason. PHP returns an undefined index error, but the index is clearly defined.
What am I missing here?
title[space]is not the same astitle. make SURE that the key you think should be there really IS there.var_dump()gives you far better diagnostic information, including type/size metadataprint_rs. or, better yet, as @marc says, do a var_dump of all the data so we can see clearly how it is structured.