0

I have a 2 dimensional array like below. How to print output to execl with number of columns = length of array parent. In each column, the data in the sub-array is foreach and filled vertically similar to the illustration.

  • I use Laravel 6.2, maatwebsite/excel 3.2
[
0 => [
0 => ["cid" => "99201000000001"],
1 => ["cid" => "99201000000002"],
2 => ["cid" => "99201000000003"],
3 => ["cid" => "99201000000004"],
4 => ["cid" => "99201000000005"],
5 => ["cid" => "99201000000006"],
6 => ["cid" => "99201000000007"],
7 => ["cid" => "99201000000008"]
],
1 => [
0 => ["cid" => "99201000000001"],
1 => ["cid" => "99201000000002"],
2 => ["cid" => "99201000000003"],
3 => ["cid" => "99201000000004"],
4 => ["cid" => "99201000000005"]
],
2 => [
0 => ["cid" => "99201000000001"],
1 => ["cid" => "99201000000002"],
2 => ["cid" => "99201000000003"],
3 => ["cid" => "99201000000004"],
4 => ["cid" => "99201000000005"]
],
3 => [
0 => ["cid" => "99201000000001"],
1 => ["cid" => "99201000000002"],
2 => ["cid" => "99201000000003"]
],
4 => [
0 => ["cid" => "99201000000001"]
],
5 => [],
6 => []
]

enter image description here

I tried with this code but it's not right

<table class="table table-bordered">
    <thead>
        <tr>
            @foreach($usersData as $key => $value)
            <th width="25" style="background-color: #227447; color: #ffffff; border: 1px solid #f2f2f2">{{++$key}} 台紙</th>
            @endforeach
        </tr>
    </thead>
    <tbody>
        <tr>
            @foreach($usersData as $key => $userList)
            @foreach($userList as $key => $user)
            <td>
                {{$user['cid']}}
            </td>
            @endforeach
            @endforeach
        </tr>
    </tbody>
</table>

0 Answers0