title: Displaying images from array using a foreach loop
body: <p>I have a foreach loop to display images like so:</p>
  
  <pre><code>&lt;? foreach ($fmx as $key): ?&gt;
      &lt;li class="span3"&gt;
          &lt;div class="thumbnail"&gt;                             
              &lt;h5 class ="cv-img-header"&gt;FMX&lt;/h5&gt;                                
                  &lt;div class="cv-icon-eye"&gt;
                      &lt;a href="#fmx" role = "button" class = "icon-eye-open" data-toggle="modal"&gt; &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;img src="&lt;?= site_url('/files/fmx/' .$id.'/'.$var.'/fmx/'. $key["file_name"]); ?&gt;"&gt;    
              &lt;div id="fmx" class="modal hide fade cv-img-modal" tabindex="-1" role="dialog" aria-labelledby="fmx" aria-hidden="true"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
                      &lt;h3&gt;FMX&lt;/h3&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt; 
                      &lt;p&gt;&lt;img src="&lt;?= site_url('/files/fmx/' .$id.'/'.$var.'/fmx/'. $key["file_name"]); ?&gt;"&gt;&lt;/p&gt;                         
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button class="btn btn-primary cv-modal-btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt;
                  &lt;/div&gt;
               &lt;/div&gt;
          &lt;/div&gt;
       &lt;/li&gt;
  
  &lt;? endforeach;?&gt;
  </code></pre>
  
  <p>The images are all displayed in the thumbnail dic has they should be, however, when I click to open the modal window, the image is always the first element of the array(The modal opens a bigger view of the image). How can I have each modal image correspond with the thubnail image?</p>
  
  <p>The array: Some elements have been cut out because I dont know how to format them here in a readable way.</p>
  
  <pre><code> array(22) {
   [0]=&gt;
   array(1) {
   ["file_name"]=&gt;
    string(37) "e00f50e3b0cf9a96357f16761e10d7a9.jpeg"
   }
   [1]=&gt;
   array(1) {
   ["file_name"]=&gt;
   string(37) "e3f07180d4a01cca8021f0b31142840e.jpeg"
   }
   [2]=&gt;
   array(1) {
   ["file_name"]=&gt;
   string(37) "c52127da0a36d737da527c2c32f07b9d.jpeg"
   }
   [3]=&gt;
   array(1) {
   ["file_name"]=&gt;
   string(37) "1339aa888b253a50900e2e3c236b58f8.jpeg"
   }
  </code></pre>