How to put the numbering of elements in php without html?

Hi all. Tell me, please, is there in php a possibility of setting of the numbering. Maybe without using the tags ol and Li. Or cyclically. And then I have the table and the validator complains much.
I need to get a structure like this
1.
1.1
1.1.1
1.1.2
and so on
<?
$previousLevel = 0;
foreach($arResult["SECTIONS"] as $arSection):?>

 <?if ($arSection["DEPTH_LEVEL"] == 1):?> 
 the <div><?=$arSection["NAME"]?><</div> //Elements 1. (2. 3. and so on. first level)
<?else:?>
 <h3><?=$arSection['NAME']?></h3>//elements 1.1. (2.1 and so on second level)
 <?if (!empty($arSection["ITEMS"])):?> //table of elements of type 1.1.1 (2.1.1 and so on. third level)
 <table class="table">
 <tbody class="hideseek">
 <?foreach($arSection["ITEMS"] as $arItem):?>
 <tr id="<?=$this->GetEditAreaId($arItem['ID']);?>">
<td><?=$arItem["NAME"]?></td>
<td><?=$arItem["DISPLAY_PROPERTIES"]["PRICE"]["a display_value"]?></td>
</tr>
<?endforeach?>
</tbody>
 </table> 
 <?endif?> 
<?endif?
 <?$previousLevel = $arSection["DEPTH_LEVEL"];?>
<?endforeach?>
June 27th 19 at 15:34
1 answer
June 27th 19 at 15:36
Solution
<?php 
$i = 1;
foreach($arResult["SECTIONS"] as $arSection):?>
 echo $i;
 $k = 1;
 <?foreach($arSection["ITEMS"] as $arItem):?>
 echo $i . '.' . $k;
$k++;
 <?php endforeach; ?>
$i++;
<?php endforeach; ?>

Find more questions by tags PHP