title: read individual img src from folder contents into HTML
body: <p>I am trying to write some simple code, but I am not sure what to use, javascript or PHP.
  I have some structured HTML docs and I want to insert an image from a folder into each img src attribute.
  So basically I would need to read in the contents and then insert each one, one by one.</p>
  
  <pre><code>&lt;div class="slideshow"&gt;
          &lt;div class="wrapper"&gt;
              &lt;ul&gt;
                  &lt;li&gt;
                      &lt;div class="main"&gt;
                          &lt;a href="product1.html"&gt;&lt;img src="images/sample/name1-1.jpg" alt="" width="630" height="400" /&gt;&lt;/a&gt;
                      &lt;/div&gt;
                      &lt;div class="second"&gt;
                          &lt;img src="images/sample/name1-2.jpg" alt="" width="310" height="190" /&gt;
                      &lt;/div&gt;
                      &lt;div class="third"&gt;
                          &lt;img src="images/sample/name1-3.jpg" alt="" width="310" height="190" /&gt;
                      &lt;/div&gt;
                  &lt;/li&gt;
  </code></pre>
  
  <p>Thanks to anyone who might be able to steer me in the right direction..</p>
  
  <p>I am using the following code to get the images from the directory</p>
  
  <pre><code>&lt;?php
  
  Header("content-type: application/x-javascript");
  
  function returnimages($dirname=".") {
  $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)"; 
  $files = array();
  $curimage=0;
  if($handle = opendir($dirname)) {
  while(false !== ($file = readdir($handle))){
  if(eregi($pattern, $file)){ 
  
  echo 'galleryarray['.$curimage.']="'.$file .'";';
  $curimage++;
  }
  }
  
  closedir($handle);
  }
  return($files);
  }
  
  echo 'var galleryarray=new Array();'; 
  returnimages() 
  ?&gt;
  </code></pre>
  
  <p>but at this point I am not sure how to insert each file name into the src attribute</p>