Rebuild DIV id's
<p>I have a piece of php that outputs divs (depending on how many is in the array) and assigns that div with an id (i.e div_1, div_2) etc</p>

<p>I also set a hidden field with the count of how many divs were outputted (divcount)</p>

<p>So lets say I have 5 divs then the id's of the div's will be</p>

<ul>
<li>div_1, </li>
<li>div_2,</li>
<li>div_3</li>
<li>etc etc</li>
<li>and the hidden field (divcount) will be set to 5</li>
</ul>

<p>If div_2 gets deleted, I set the divcount hidden field to 4. </p>

<p>What I need to do now is rebuild the other div's id's to be:</p>

<ul>
<li>div_1,</li>
<li>div_2,</li>
<li>div_3,</li>
<li>div_4,
but currently I am left with div_1, div_3, div_4, div_5</li>
</ul>

<p>I guess I need a loop to loop through each div and assign the id of THAT div the value of the loop </p>

<p>i.e </p>

<ul>
<li>div_1 id becomes div_1</li>
<li>div_3 id becomes div_2</li>
<li>div_4 id becomes div_3</li>
<li>div_5 id becomes div_4</li>
</ul>

<p>Can anyone advise on how to do this?</p>

<p>Thanks in advance!</p>
