Broken php array indexing -


there must obvious i'm doing wrong here, i've spent hours trying figure out , 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 $b){     print_r($b);     print_r($b['category']);         print_r($b['title']); ///wtf.    }  ?> 

the array returned json request has indices both category , title, returns null title. several other elements json array return null reason. php returns undefined index error, index defined.

what missing here?

the title index under related_bill, not main objects array.

this should work:

foreach($bills $b){     print_r($b);     print_r($b['category']);         print_r($b['related_bill']['title']); } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -