<?php foreach($header as $rowItem): ?>
<tr>
<?php foreach($rowItem as $headerItem): ?>
<th data-tablesaw-priority="persist" id="<?= $headerItem['id'] ?>" class="<?= $headerItem['class'] ?>"
<?= (isset($headerItem['colspan']))?'colspan="'. $headerItem['colspan'] .'"':'' ?>
<?= (isset($headerItem['rowspan']))?'rowspan="'. $headerItem['rowspan'] .'"':'' ?>
<?= (isset($headerItem['style']))?'style="'. $headerItem['style'] .'"':'' ?> >
<?= $headerItem['text'] ?>
</th>
<?php endforeach ?>
</tr>
<?php endforeach ?>
This loop will have three <tr> tags. Now you need to add custom attributes to the <th> in the second <tr> tag. How does this need to be written?
The simplest, if judgment loops out the key
Method 1, use foreach, add a count variable, record the number of loops, if $count == 1, do what you need to do next
Method 2, use for, do what you need to do when $i==1