@Kvandaik

Как получить несколько массивов?

есть большой массив $ramb выглядит так
$ramb
Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [label] => pam1
                            [y] => 1
                        )

                )

            [1] => Array
                (
                    [0] => Array
                        (
                            [label] => pam2
                            [y] => 3
                        )

                )

            [2] => Array
                (
                    [0] => Array
                        (
                            [label] => pam3
                            [y] => 2
                        )

                )

            [3] => Array
                (
                    [0] => Array
                        (
                            [label] => pam4
                            [y] => 3
                        )

                )

            [4] => Array
                (
                    [0] => Array
                        (
                            [label] => pam5
                            [y] => 4
                        )

                )

            [5] => Array
                (
                    [0] => Array
                        (
                            [label] => pam6
                            [y] => 4
                        )

                )

            [6] => Array
                (
                    [0] => Array
                        (
                            [label] => pam7
                            [y] => 4
                        )

                )

            [7] => Array
                (
                    [0] => Array
                        (
                            [label] => pam8
                            [y] => 6
                        )

                )

            [8] => Array
                (
                    [0] => Array
                        (
                            [label] => pam9
                            [y] => 1
                        )

                )

        )

    [1] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [label] => pam1
                            [y] => 2
                        )

                )

            [1] => Array
                (
                    [0] => Array
                        (
                            [label] => pam2
                            [y] => 2
                        )

                )

            [2] => Array
                (
                    [0] => Array
                        (
                            [label] => pam3
                            [y] => 4
                        )

                )

            [3] => Array
                (
                    [0] => Array
                        (
                            [label] => pam4
                            [y] => 2
                        )

                )

            [4] => Array
                (
                    [0] => Array
                        (
                            [label] => pam5
                            [y] => 4
                        )

                )

            [5] => Array
                (
                    [0] => Array
                        (
                            [label] => pam6
                            [y] => 4
                        )

                )

            [6] => Array
                (
                    [0] => Array
                        (
                            [label] => pam7
                            [y] => 5
                        )

                )

            [7] => Array
                (
                    [0] => Array
                        (
                            [label] => pam8
                            [y] => 2
                        )

                )

            [8] => Array
                (
                    [0] => Array
                        (
                            [label] => pam9
                            [y] => 5
                        )

                )

        )

    [2] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [label] => pam1
                            [y] => 3
                        )

                )

            [1] => Array
                (
                    [0] => Array
                        (
                            [label] => pam2
                            [y] => 2
                        )

                )

            [2] => Array
                (
                    [0] => Array
                        (
                            [label] => pam3
                            [y] => 3
                        )

                )

            [3] => Array
                (
                    [0] => Array
                        (
                            [label] => pam4
                            [y] => 5
                        )

                )

            [4] => Array
                (
                    [0] => Array
                        (
                            [label] => pam5
                            [y] => 1
                        )

                )

            [5] => Array
                (
                    [0] => Array
                        (
                            [label] => pam6
                            [y] => 4
                        )

                )

            [6] => Array
                (
                    [0] => Array
                        (
                            [label] => pam7
                            [y] => 4
                        )

                )

            [7] => Array
                (
                    [0] => Array
                        (
                            [label] => pam8
                            [y] => 7
                        )

                )

            [8] => Array
                (
                    [0] => Array
                        (
                            [label] => pam9
                            [y] => 3
                        )

                )

        )

)

в нём повторяется меньшие массивы с переодичночтью 3 по 9 шт, мне нужно было разделить на 3 массива
for($i = 0; $i <= $chess-1; $i++) {
${'result'.$i}=array_merge($ramb[$i][0],$ramb[$i][1],$ramb[$i][2],$ramb[$i][3],$ramb[$i][4],$ramb[$i][5],$ramb[$i][6],$ramb[$i][7],$ramb[$i][8]);

}

сделал так, вот что получилось допустим $result0;
$result0;
Array
(
    [0] => Array
        (
            [label] => pam1
            [y] => 1
        )

    [1] => Array
        (
            [label] => pam2
            [y] => 3
        )

    [2] => Array
        (
            [label] => pam3
            [y] => 2
        )

    [3] => Array
        (
            [label] => pam4
            [y] => 3
        )

    [4] => Array
        (
            [label] => pam5
            [y] => 4
        )

    [5] => Array
        (
            [label] => pam6
            [y] => 4
        )

    [6] => Array
        (
            [label] => pam7
            [y] => 4
        )

    [7] => Array
        (
            [label] => pam8
            [y] => 6
        )

    [8] => Array
        (
            [label] => pam9
            [y] => 1
        )

)

Вопрос как сделать так чтоб вручную не делать
array_merge($ramb[$i][0],$ramb[$i][1],$ramb[$i][2],$ramb[$i][3],$ramb[$i][4],$ramb[$i][5],$ramb[$i][6],$ramb[$i][7],$ramb[$i][8]);
  • Вопрос задан
  • 75 просмотров
Решения вопроса 2
VladimirAndreev
@VladimirAndreev
php web dev
\array_merge(...$ramb);
Ответ написан
Комментировать
TommyV888
@TommyV888 Куратор тега PHP
-
array_merge(...$ramb[$i]);
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Похожие вопросы