title: dynamic php list with foreach loop
body: <p>Trying to build a dynamic gallery that is loaded via AJAX.</p>
  
  <p>I'm trying to get it to build a <code>ul</code> with as many <code>list items</code> as there are pictures, because each gallery has a different amount of images... something like this:</p>
  
  <pre><code>&lt;ul id="foo"&gt;
   &lt;li&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="../images/portfolio/foo/001.jpg&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="../images/portfolio/foo/002.jpg&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;div class="description"&gt;FOO TITLE / DESCRIPTION&lt;/div&gt;
  
  &lt;ul id="bar"&gt;
   &lt;li&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="../images/portfolio/bar/001.jpg&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="../images/portfolio/bar/002.jpg&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="../images/portfolio/bar/003.jpg&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;div class="description"&gt;BAR TITLE / DESCRIPTION&lt;/div&gt;
  </code></pre>
  
  <p>I'm not familiar enough with PHP to build in the foreach to the function I've built. Any help? Here is what I have so far (note the array I have is a temporary solution... it doesn't work if the project has less/more than the 4 that I've listed in the array):</p>
  
  <pre><code>&lt;?php function generateProject($projTitle,$projDesc) {
  
  $proj = $_GET['proj'];
  
  echo '&lt;ul id="'.$proj.'"&gt;';
  
  $array = array('001','002','003','004');
  
      foreach($array as $picture)
      {
          echo '&lt;li&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="../images/portfolio/'.$proj.'/'.$picture.'.jpg"';
          echo '&lt;/li&gt;';
      }
  
  echo '&lt;/ul&gt;';
  
  echo '&lt;div class="description"&gt;'.$projTitle.' &lt;span class="slash"&gt;&amp;nbsp;/&amp;nbsp;&lt;/span&gt;'.$projDesc.'&lt;/div&gt;';
  
  } ?&gt;
  
  
  &lt;?php
      generateProject(
      'deadAWESOME',
      'Gargoyles. Dusty leather tomes. Hidden rooms. Coffee.');
  ?&gt;
  </code></pre>