在php中循环打印列的名称

时间:2021-06-08 20:53:13

标签: javascript php jquery arrays html-table

因此,如果我在 PHP 中有一个循环并打印列的名称,例如:

<?php foreach ($allColumns as $columnValues): ?>
            <th scope="col">

                <?php echo $columnValues ?>

                <button type="submit" name="exchange">
                   <i class="fas fa-exchange-alt" style="float: right; cursor: pointer"></i>
                </button>

            </th>
<?php endforeach; ?>

所以我会有一张这样的桌子

enter image description here

因此,每当我单击其中一个交换图标时,我都想打印该列的名称。 我该怎么做?

更新: 打印它不是重点。我只是想找到一种方法来获取该特定列而不是所有列。因为如果我尝试在循环内打印它,它将打印所有它们,而在循环外我无权访问 $columnValues

0 个答案:

没有答案