create a structured table from a random array

  arrays, html-table, loops, php

here I am trying to make an application. but there is a problem with this problem, I try to group the data that I have but I am confused to do it.

in my case using array looks like this.

$data = [
    "results" => [
        0 => [ // as C1
            0 => [
                0 => '4',
                1 => '2',
                2 => '3'
            ],
            5 => [
                0 => '3',
                1 => '3',
                2 => '2'
            ],
            6 => [
                0 => '4',
                1 => '3',
                2 => '2',
            ]
        ],
        1 => [ // as C2
            2 => [
                0 => '2',
                1 => '5',
                2 => '1'
            ],
            4 => [
                0 => '2',
                1 => '3',
                2 => '2'
            ]
        ],
        2 => [ // as C3
            1 => [
                0 => '2',
                1 => '1',
                2 => '3'
            ],
            3 => [
                0 => '2',
                1 => '1',
                2 => '3'
            ],
            7 => [
                0 => '2',
                1 => '1',
                2 => '3'
            ]
        ]
    ],

    "samples" => [
        0 => [
            0 => '4',
            1 => '2',
            2 => '3'
        ],
        1 => [
            0 => '2',
            1 => '1',
            2 => '3'
        ],
        2 => [
            0 => '2',
            1 => '5',
            2 => '1'
        ],
        3 => [
            0 => '2',
            1 => '1',
            2 => '3'
        ],
        4 => [
            0 => '2',
            1 => '3',
            2 => '2'
        ],
        5 => [
            0 => '3',
            1 => '3',
            2 => '2'
        ],
        6 => [
            0 => '4',
            1 => '3',
            2 => '2'
        ],
        7 => [
            0 => '2',
            1 => '1',
            2 => '3'
        ]
    ],

    "lables" => [
        0 => 'Lable 1',
        1 => 'Lable 2',
        2 => 'Lable 3',
        3 => 'Lable 4',
        4 => 'Lable 5',
        5 => 'Lable 6',
        6 => 'Lable 7',
        7 => 'Lable 8'
    ],

    "column" => [
        0 => 'dependents',
        1 => 'Profession',
        2 => 'Income'
    ]

];

where in array 0, 1, 2 in array results will be used as C1, C2, C3
and I want to match the results with samples to put C1, C2, C3.
the constraint is that the results array is a shuffled array of samples.

because the existing array looks terrible in my opinion and difficult to achieve the goal I want.

guess i want to make like this, with table in html.

enter image description here

please help me solve this confusion problem i’m having?

Source: Ask PHP

LEAVE A COMMENT