i have a veriable named (num) which is used for increments changes names of ids by 1 num+1 but in my foreachloop i cant access it .
i tried declaring it before the loop still doesnot work
<?php $num = 0; ?>
<?php foreach($listings as $list):?>
<li>
<div class="checkbox">
<input type="checkbox" class="css-checkbox" value="<?php echo $list['title'];?>" id="visit<?php echo $num+1;?>" name="treatment<?php echo $num+1;?>">
<label for="visit<?php echo $num+1;?>" class="css-label"><?php echo $list['title']?> <strong><?php echo $list['price'];?><span>£</span></strong></label>
</div>
</li>
<?php endforeach; ?>
</ul>
<hr>
<input type="hidden" value="<?php echo $num;?>" name="total"/>
i want the input ids to be incremented by 1 like treatment1,treatment2
... as $num => $listand skip the outside declaration of$num