How to number div loop in php?

In php file but is not working

$i = 0;
foreach($items as $item) { 
$i++;

echo '<div class="row">';
echo '<div class="col-1">';
echo $i;
echo '</div>';
echo '<div class="col-2">2</div>';
echo '<div class="col-3">3</div>';
echo '<div class="col-4">4</div>';
echo '<div class="col-5">5</div>';
echo '</div>';

echo '<div class="row">';
echo '<div class="col-1">';
echo $i;
echo '</div>';
echo '<div class="col-2">2</div>';
echo '<div class="col-3">3</div>';
echo '<div class="col-4">4</div>';
echo '<div class="col-5">5</div>';
echo '</div>';

echo '<div class="row">';
echo '<div class="col-1">';
echo $i;
echo '</div>';
echo '<div class="col-2">2</div>';
echo '<div class="col-3">3</div>';
echo '<div class="col-4">4</div>';
echo '<div class="col-5">5</div>';
echo '</div>';

}


Need to number himself with div 1

<div class="col-1">here the numbering 1</div>
June 3rd 19 at 20:19
1 answer
June 3rd 19 at 20:21
Create an array of the following form:
$items = array(
0 => '0',
1 => 'Value1'
);

And then insert the following and number of created div will be equal to the count of elements in the array:
<?foreach($items as $key =--> $item)?>
 <div class="col-<?=$key?>"><?=$item?></div>
 <?endforeach?>
not that the list changes every time - Peter.Oberbrunner84 commented on June 3rd 19 at 20:24
More is possible? How has it changed? - Salvatore_OKee commented on June 3rd 19 at 20:27

Find more questions by tags PHPHTML