What makes this work?
<p>I am trying to use this chunk of code as template, but Im not fully understanding of how one line works. I'll first provide the full chunk, then I'll single out the line I don't understand.</p>

<pre><code>/** settings **/
$images_dir = 'preload-images/';
$thumbs_dir = 'preload-images-thumbs/';
$thumbs_width = 200;
$images_per_row = 3;

/** generate photo gallery **/
$image_files = get_files($images_dir);
if(count($image_files)) {
$index = 0;
foreach($image_files as $index=&gt;$file) {
    $index++;
    $thumbnail_image = $thumbs_dir.$file;
    if(!file_exists($thumbnail_image)) {
        $extension = get_file_extension($thumbnail_image);
        if($extension) {
            make_thumb($images_dir.$file,$thumbnail_image,$thumbs_width);
        }
    }
    echo '&lt;a href="',$images_dir.$file,'" class="photo-link smoothbox" rel="gallery"&gt;&lt;img src="',$thumbnail_image,'" /&gt;&lt;/a&gt;';
    if($index % $images_per_row == 0) { echo '&lt;div class="clear"&gt;&lt;/div&gt;'; }
}
echo '&lt;div class="clear"&gt;&lt;/div&gt;';
}
else {
echo '&lt;p&gt;There are no images in this gallery.&lt;/p&gt;';
}
</code></pre>

<p>I understand how everything with the exception of this line works.</p>

<pre><code>if($index % $images_per_row == 0) { echo '&lt;div class="clear"&gt;&lt;/div&gt;'; }
</code></pre>

<p>I know it is getting its value from this line:</p>

<pre><code>$images_per_row = 3;
</code></pre>

<p>But what actually makes this work? Im still pretty new to php, and I would like a better understanding of the code Im about to use before I use it.</p>

<p>Any answers at all would be appreciative!</p>