как создать таблицу (rowspan & colsopan) с этим массивом - PullRequest
0 голосов
/ 30 апреля 2019

у меня есть такой массив

$json = [
            ['No.',"Nama","Luas","D1",null,"D2","DL",null,null],
            [null,null,null,"val1","val2","zal1","yal1",'yal2','yal3'],
        ];

что я пробовал

foreach($firstHeader as $index => $row) {
                if($firstHeader[$index] === null) {
                    if($firstHeader[$index - 1] != null) {
                        \Log::info([$firstHeader[$index - 1], $counter]);
                    }
                    $counter++;
                    $html .= '<th colspan="'.($counter + 1).'">'. $firstHeader[$index - 1] . '</th>';
                } else {
                    $counter = 0;
                    if($secondHeader[$index] === null && $row !== null) {
                        $html .= '<th rowspan="2">'. $firstHeader[$index] . '</th>';
                    }

                    if($firstHeader[$index] != null) {
                        \Log::info([$firstHeader[$index], $counter]);
                    }
                }

            }

мой ожидаемый результат

https://ibb.co/R7P9Vrm

enter image description here

спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...