A
A
Alexey Nikolaev2015-11-17 22:01:59
PHP
Alexey Nikolaev, 2015-11-17 22:01:59

How to automatically number lines in php?

There is a table

<table>
<tr> 
<td>1</td> 
</tr>
<tr> 
<td>2</td> 
</tr>
<tr> 
<td>3</td> 
</tr>
</table>

How to display numbers using php? Number the lines i.e.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anar4you, 2015-11-17
@Anar4you

Loop:
for ($i = 1; $i <= 10; $i++) {
echo $i;
}

A
Andrew, 2015-11-17
@R0dger

<?php 
$arr = array(1, 2, 3, 4); ?>
<table>
  <?php foreach ($arr as $val):?>
    <tr>
       <td><?= $val;?></td>
    </tr>
  <?php endforeach;?>
</table>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question