Извлечь данные из текстового файла

Привет у меня есть текстовый файл с содержимым, как это:

{"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"}

Я хочу извлечь из нее информацию и показать ее на моем сайте.

-2

Решение

Поскольку это текст в формате 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"}
1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector