I can't get an Array

I'm trying to grab a value inside an array, but it doesn't print anything from the id field, which is the field I want to grab

$jsonc = file_get_contents("https://api.themoviedb.org/3/search/tv?query=todo%20o%20mundo%20odeia%20o%20chris&api_key=b5ad6a9f75ea4e476b5f08b524ddf83d");
$epjson = json_decode($jsonc);    
print_r($epjson -> id);

Note: when I do only print_r($epjson); print this:

StdClass Object ([page] = > 1 [total_results] = > 1 [total_pages] = > 1 [results] => Array ([0] => stdClass Object ([original_name] = > Everybody Hates Chris [id] = > 252 [name] = > Everybody Hates Chris [vote_count] = > 68 [vote_average] = > 6.82 [poster_path] => / dM0IUKmrjyhFskt0ZBMbbfWxRIQ.jpg [first_air_date] = > 2005-09-22 [popularity] = > 10.150596 [genre_ids] = > Array ([0] => 35 ) [original_language] = > in [backdrop_path] => / xYLcbJoQEowXFVqe94A37CIC0Tq.jpg [overview] = > Everybody Hates Chris is an American television narrative sitcom that depicts the troubled teenage experiences of comedian Chris Rock while growing up in Bedford-Stuyvesant, Brooklyn, New York City. The show is set between 1982 and 1987, but Rock himself was a teenager between 1978 and 1983. Rock grew up with a boy named Kenny Montero, whom he has often referred to as the inspiration for a lot of the episodes. In many of his interviews, Rock has described Kenny as the reason he got into comedy in the first place. The show's title parodies the hit CBS sitcom Everybody Loves Raymond, in which Rock stated: "Everybody Loves Raymond, but Everybody Hates Chris!". The show's lead actors are Tyler James Williams, Terry Crews, Tichina Arnold, Tequan Richmond, Imani Hakim, and Vincent Martella. In 2008, The CW moved Everybody Hates Chris and the Game to the Friday night death slot. The fourth season of the series premiered Friday, October 3, 2008, at 8: 00PM Eastern / 7: 00pm Central. On May 21, 2009, The CW announced that it had canceled Everybody Hates Chris. Prior to this, Rock announced that the end of season 4 matched up with his own past-dropping out of high school to become a comedian-and that it was time to end the show. [origin_country] = > Array ([0] => US))))

Author: Isac, 2017-11-22

1 answers

Notice the structure of the information in the API you are using:

{
    "page": 1,
    "total_results": 1,
    "total_pages": 1,
    "results": [{
                "original_name": "Everybody Hates Chris",
                "id": 252,
                "name": "Everybody Hates Chris",
                "vote_count": 68,
                ....

The id is not just in the root but inside the array results, so you must access it with:

print_r($epjson->results[0]->id);

If you have more than one result and want the id of the various results you should use a for to scroll through them.

 1
Author: Isac, 2017-11-22 23:09:48