Как разобрать массив на переменные и записать в базу?

Получаю по api массив из данных
$array = array();

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://shikimori.org/api/animes/31637');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "User Agent");
if ($content = curl_exec($ch)) {
  $array = json_decode($content, true);  
}
curl_close($ch);

echo '<pre>';
print_r($array);

Массив
Array
(
    [id] => 31637
    [name] => Gate: Jieitai Kanochi nite, Kaku Tatakaeri 2nd Season
    [russian] => Врата: Там бьются наши воины — Огнедышащие драконы
    [image] => Array
        (
            [original] => /images/anime/original/31637.jpg?1453660380
            [preview] => /images/anime/preview/31637.jpg?1453660380
            [x96] => /images/anime/x96/31637.jpg?1453660380
            [x48] => /images/anime/x48/31637.jpg?1453660380
        )

    [url] => /animes/31637-gate-jieitai-kanochi-nite-kaku-tatakaeri-2nd-season
    [kind] => tv
    [ongoing] => 1
    [anons] => 
    [status] => ongoing
    [episodes] => 12
    [episodes_aired] => 4
    [rating] => r
    [english] => Array
        (
        )

    [japanese] => Array
        (
            [0] => GATE(ゲート)自衛隊 彼の地にて、斯く戦えり 第2クール
        )

    [synonyms] => Array
        (
            [0] => Gate: Thus the JSDF Fought There! Fire Dragon Arc
            [1] => Gate: Jieitai Kanochi nite
            [2] => Kaku Tatakaeri - Enryuu-hen
            [3] => Gate Jieitai Kanochi Nite Kaku Tatakaeri 2nd Season
        )

    [aired_on] => 2016-01-09
    [released_on] => 2016-03-26
    [duration] => 23
    [score] => 8.17
    [description] => Second season of the [i]Gate[/i] anime. Adapts Enryuu-hen, and Douran-hen arcs.
    [description_html] => Second season of the Gate anime. Adapts Enryuu-hen, and Douran-hen arcs.
    [favoured] => 
    [thread_id] => 184926
    [world_art_id] => 0
    [myanimelist_id] => 31637
    [ani_db_id] => 0
    [rates_scores_stats] => Array
        (
            [0] => Array
                (
                    [name] => 10
                    [value] => 231
                )

            [1] => Array
                (
                    [name] => 9
                    [value] => 99
                )

            [2] => Array
                (
                    [name] => 8
                    [value] => 84
                )

            [3] => Array
                (
                    [name] => 7
                    [value] => 35
                )

            [4] => Array
                (
                    [name] => 6
                    [value] => 15
                )

            [5] => Array
                (
                    [name] => 5
                    [value] => 3
                )

            [6] => Array
                (
                    [name] => 3
                    [value] => 1
                )

            [7] => Array
                (
                    [name] => 1
                    [value] => 1
                )

        )

    [rates_statuses_stats] => Array
        (
            [0] => Array
                (
                    [name] => Запланировано
                    [value] => 2303
                )

            [1] => Array
                (
                    [name] => Смотрю
                    [value] => 2023
                )

            [2] => Array
                (
                    [name] => Просмотрено
                    [value] => 34
                )

            [3] => Array
                (
                    [name] => Отложено
                    [value] => 52
                )

            [4] => Array
                (
                    [name] => Брошено
                    [value] => 7
                )

        )

    [genres] => Array
        (
            [0] => Array
                (
                    [id] => 2
                    [name] => Adventure
                    [russian] => Приключения
                    [kind] => anime
                )

            [1] => Array
                (
                    [id] => 1
                    [name] => Action
                    [russian] => Экшен
                    [kind] => anime
                )

            [2] => Array
                (
                    [id] => 38
                    [name] => Military
                    [russian] => Военное
                    [kind] => anime
                )

            [3] => Array
                (
                    [id] => 10
                    [name] => Fantasy
                    [russian] => Фэнтези
                    [kind] => anime
                )

        )

    [studios] => Array
        (
            [0] => Array
                (
                    [id] => 56
                    [name] => A-1 Pictures Inc.
                    [filtered_name] => A-1 Pictures Inc.
                    [real] => 1
                    [image] => /images/studio/original/56.?1434707196
                )

        )

    [videos] => Array
        (
            [0] => Array
                (
                    [id] => 11435
                    [url] => http://youtu.be/oPfeTTcZGhs
                    [image_url] => http://shikimori.org/images/31637
                    [player_url] => http://youtube.com/embed/oPfeTTcZGhs
                    [name] => 
                    [kind] => PV
                    [hosting] => youtube
                )

            [1] => Array
                (
                    [id] => 12579
                    [url] => http://youtu.be/TrwXsOTWUeU
                    [image_url] => http://shikimori.org/images/31637
                    [player_url] => http://youtube.com/embed/TrwXsOTWUeU
                    [name] => 
                    [kind] => PV
                    [hosting] => youtube
                )

        )

    [screenshots] => Array
        (
        )

    [user_rate] => 
)

Как его разобрать на переменные для записи в базу?
+ будет даже ссылка или информация куда копать в эту сторону
  • Вопрос задан
  • 889 просмотров
Решения вопроса 1
@crazyhat
Web разработчик
А зачем его разбивать в переменные? Можно для записи использовать элементы массива. Например:
$array['id]
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 18:38
1500 руб./в час
19 апр. 2024, в 18:36
1500 руб./за проект
19 апр. 2024, в 18:36
30000 руб./за проект