<?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?
学习ing2017-06-29 10:10:29
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
for($i=0;$i<count($header);$i++)
{
if($i === 1) {
//
}else{
//
}
}