您好我有一个包含以下内容的文本文件:
{"Title":"Hot Tub Time Machine 2","Year":"2015","Rated":"R","Released":"20 Feb 2015","Runtime":"93 min","Genre":"Comedy, Sci-Fi","Director":"Steve Pink","Writer":"Josh Heald (characters), Josh Heald","Actors":"Adam Scott, Gillian Jacobs, Thomas Lennon, Chevy Chase","Plot":"When Lou, who has become the \"father of the Internet,\" is shot by an unknown assailant, Jacob and Nick fire up the time machine again to save their friend.","Language":"English","Country":"USA","Awards":"N/A","Poster":"http://ia.media-imdb.com/images/M/MV5BMTU3NzQzMzE0NV5BMl5BanBnXkFtZTgwMDM4MTI0NDE@._V1_SX300.jpg","Metascore":"N/A","imdbRating":"N/A","imdbVotes":"N/A","imdbID":"tt2637294","Type":"movie","Response":"True"}
我想从中提取信息并在我的网站上显示。
答案 0 :(得分:1)
由于它是JSON文本,您可以使用以下内容:
$content = file_get_contents('http://mo4vies.esy.es/wp-content/uploads/imdbcache/tt2637294.txt');
$contentArray = json_decode($content, true);
$contentArray
将是一个具有如下结构的关联数组:
array(20) {
["Title"]=>
string(22) "Hot Tub Time Machine 2"
["Year"]=>
string(4) "2015"
["Rated"]=>
string(1) "R"
["Released"]=>
string(11) "20 Feb 2015"
["Runtime"]=>
string(6) "93 min"
["Genre"]=>
string(14) "Comedy, Sci-Fi"
["Director"]=>
string(10) "Steve Pink"
["Writer"]=>
string(35) "Josh Heald (characters), Josh Heald"
["Actors"]=>
string(54) "Adam Scott, Gillian Jacobs, Thomas Lennon, Chevy Chase"
["Plot"]=>
string(155) "When Lou, who has become the "father of the Internet," is shot by an unknown assailant, Jacob and Nick fire up the time machine again to save their friend."
["Language"]=>
string(7) "English"
["Country"]=>
string(3) "USA"
["Awards"]=>
string(3) "N/A"
["Poster"]=>
string(96) "http://ia.media- imdb.com/images/M/MV5BMTU3NzQzMzE0NV5BMl5BanBnXkFtZTgwMDM4MTI0NDE@._V1_SX300.jpg"
["Metascore"]=>
string(3) "N/A"
["imdbRating"]=>
string(3) "N/A"
["imdbVotes"]=>
string(3) "N/A"
["imdbID"]=>
string(9) "tt2637294"
["Type"]=>
string(5) "movie"
["Response"]=>
string(4) "True"
}