So I have a table which is generated by a foreach loop. Within the table the id is used to load a modal. I wonder how I can generate a numircal sequence starting from 1, then 2, 3 and so on. I am aware that I can use http://www.php.net/manual/en/function.sprintf.php for this, but I don´t know how to use is within the existing loop? I have market the placement within the code with ????
The reason I want to do this is to add some structure for the reader, it will have no other function.
code:
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Fråga:</th>
</tr>
</thead>
<tbody>
<?php foreach ($modals as $key => $title) { ?>
<tr>
<td><?php ???? ?></td>
<td><a href="#cptmodal_<?php echo $title['id']; ?>" data-toggle="modal"><?php echo $title['title'];?></a></td>
</tr>
<?php } ?>
</tbody>
</table>