国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - php循環(huán)第二次時加入自訂data 屬性
滿天的星座
滿天的星座 2017-06-29 10:08:29
0
2
782
<?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 ?>

此循環(huán)會有三個<tr> 標籤,現(xiàn)在需要在第二個<tr>標籤裡的<th>新增自訂屬性。這需要如何寫?

#
滿天的星座
滿天的星座

全部回覆(2)
typecho

最簡單的,if判斷循環(huán)出來的key

學習ing

方法一,使用foreach,新增一個count變量,記錄循環(huán)次數,如果$count == 1,接下來做該做的事

方法二,使用for,在$i==1時做該做的事

for($i=0;$i<count($header);$i++)
{
    if($i === 1) {
        //
    }else{
        //
    }
}
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板