Есть примерный массив из API:
[1932] => Array
(
[title_ru] => Игра престолов
[title_en] => Game of Thrones
[year] => 2011
[token] => 9258550a799e3ea8a07a3da405df58e0
[type] => serial
[kinopoisk_id] => 464963
[world_art_id] =>
[translator] => IdeaFilm
[translator_id] => 57
[iframe_url] => http://moonwalk.cc/serial/9258550a799e3ea8a07a3da405df58e0/iframe
[seasons_count] => 2
[episodes_count] => 17
[category] =>
[block] => Array
(
[blocked_at] => 2017-07-25 15:40:11
[block_ru] => 1
[block_ua] =>
)
)
[1933] => Array
(
[title_ru] => Игра престолов
[title_en] => Game of Thrones
[year] => 2011
[token] => 666c343b49c7fb076efdcd0fcd3b572f
[type] => serial
[kinopoisk_id] => 464963
[world_art_id] =>
[translator] => Субтитры
[translator_id] => 20
[iframe_url] => http://moonwalk.cc/serial/666c343b49c7fb076efdcd0fcd3b572f/iframe
[seasons_count] => 7
[episodes_count] => 67
[category] =>
[block] => Array
(
[blocked_at] => 2017-07-25 15:41:31
[block_ru] => 1
[block_ua] =>
)
)
[1934] => Array
(
[title_ru] => Игра престолов
[title_en] => Game of Thrones
[year] => 2011
[token] => e086c6617dc40d74c46a395c1edca9eb
[type] => serial
[kinopoisk_id] => 464963
[world_art_id] =>
[translator] => Gears Media
[translator_id] => 81
[iframe_url] => http://moonwalk.cc/serial/e086c6617dc40d74c46a395c1edca9eb/iframe
[seasons_count] => 2
[episodes_count] => 17
[category] =>
[block] => Array
(
[blocked_at] => 2017-07-25 15:42:13
[block_ru] => 1
[block_ua] =>
)
)
Вопрос: Как вывести уникальные массивы с неповторяющимися значениями по имени [kinopoisk_id]
?
Пытаюсь сделать так:
$input = array_map("unserialize", array_unique(array_map("serialize", $data['report']['serials'][тут циферки]['kinopoisk_id'])));
Но ничего не выходит. И через For
не помогает, так как выводит ошибку:
Warning: array_map(): Argument #2 should be an array in Warning: array_unique() expects parameter 1 to be array, null given
Update :
$filename = 'engine/serials.txt';
$json = file_put_contents($filename, file_get_contents('http://moonwalk.cc/api/serials_foreign.json?api_token=d10a8f4368bc3a6e26b11477ad939da1'));
$file_json = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/serials.txt');
$data = json_decode($file_json,true);
$datac = $data['report']['total_count'];
for ($i=1; $i <= $datac; ++$i) {
echo $data['report']['serials'][$i]['kinopoisk_id'] . '<br>';
}