I make some API calls and fill up an array. I have identified three different ways an array element might come
array:9 [▼
0 => array:2 [▼
"jobData" => array:5 [▶]
"clientData" => array:3 [▶]
]
5 => array:3 [▼
"jobData" => array:5 [▶]
"clientData" => array:3 [▶]
"customData" => array:1 [▼
"Type of work" => array:1 [▼
"Type of work" => "Something"
]
]
]
8 => array:3 [▼
"jobData" => array:5 [▶]
"clientData" => array:3 [▶]
"customData" => array:2 [▼
"Month" => array:1 [▼
"Month" => "Aug 16"
]
"Type of work" => array:1 [▼
"Type of work" => "Something"
]
]
]
]
So Element 0 only has jobData and clientData. Element 5 has these two plus a cusomtData for Type of Work. Element 8 has everything including customData for Type of Work and Month. Custom Data will either be completely empty, contain one, or contain both.
I am trying to display this data in a table. Most of it is simple enough apart from the custom data. At the moment I have something like this
<table class="table table-bordered table-hover additionalMargin alignment reportTable">
<tr class="col-md-12 noPadding">
<thead>
<tr>
<th>Job ID</th>
<th>Job Name</th>
<th>Category</th>
<th>Client Name</th>
<th>Type of work</th>
<th>Month</th>
</tr>
</thead>
</tr>
<tbody>
@if(is_array($jobArray))
@foreach($jobArray as $array)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
@endif
</tbody>
</table>
Now because the elements in my custom data are also arrays, this means I need to do another loop for them. So I could potentially do this
@if(!empty($array['customData']))
@foreach($array['customData'] as $data)
<td></td>
<td></td>
@endforeach
@endif
The problem with the above is that it seems to create its own tds and things are not matched up properly. I am essentially seeing something like this How can I make things align up appropiately?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire