Mert METİN
Mert METİN

Reputation: 1288

Getting values from specified keys

i use imdb api

 $homepage = file_get_contents('http://www.imdbapi.com/?i='.$imdbID);
            $arr = json_decode($homepage);

In $arr i have all data about related movie.

 Maguire [Year] => 1996 [Rated] => R [Released] => 13 Dec 1996 [Genre] => Comedy, Drama, Romance, Sport [Director] => Cameron Crowe [Writer] => Cameron Crowe [Actors] => Tom Cruise, Cuba Gooding Jr., Renée Zellweger, Kelly Preston [Plot] => When a sports agent has a moral epiphany and is fired for expressing it, he decides to put his new philosophy to the test as an independent with the only athlete who stays with him. [Poster] => http://ia.media-imdb.com/images/M/MV5BMTkxNjc2NjQwOF5BMl5BanBnXkFtZTcwMDE2NDU2MQ@@._V1_SX320.jpg [Runtime] => 2 hrs 19 mins [Rating] => 7.2 [Votes] => 97329 [ID] => tt0116695 [Response] => True )

what i want is that reaching specified key's value.

Is there a function like that? For example , i will give the key=> Actors and get all actors?

Upvotes: 0

Views: 46

Answers (1)

ezakto
ezakto

Reputation: 3194

:/ Like this?

$homepage = file_get_contents('http://www.imdbapi.com/?i='.$imdbID);
$arr = json_decode($homepage, true);
print($arr['Actors']);

Upvotes: 2

Related Questions