Assign different HTML classes to elements in a PHP array
<p>I am working on some images and want to assign different classes to them in batch.</p>

<p>here is my simple code </p>

<pre><code>$image_dir = 'images';
$showimage = scandir($image_dir, 0);
unset($showimage [0],$showimage [1]);
print_r ($showimage );
</code></pre>

<p>the result is </p>

<pre><code>Array ( 
    [2] =&gt; exmapleiamge1.png 
    [3] =&gt; exmapleiamge1_1.png 
    [4] =&gt; exmapleiamge1_2.png 
    [5] =&gt; exmapleiamge2_1.png 
    [6] =&gt; exmapleiamge2_2.png 
    [7] =&gt; exmapleiamge2_3.png 
    [8] =&gt; exmapleiamge3_1.png 
    [9] =&gt; exmapleiamge3_2.png 
)
</code></pre>

<p>What I want to achieve is that, assign div class=no1 to all images from exmapleiamge1_1 to exmapleiamge1_2, and assign class=no2 images from exmapleiamge2_1 to exmapleiamge2_3, and also for class no3.... etc;</p>

<p>I think the key is to filter the numbers, is it possible someone could give me a hand as I am a php beginner and keen to learn how to do that.  </p>

<p>Many thanks in advance</p>
