title: Using PHP to fetch and display contents from a set of pages
body: <p>I have been looking into different answers to similar questions, but this looks a little too specific and complex for me to just work out something from separate solutions. I sometimes use snippets of PHP code but apart from this I am a total PHP newbie.</p>
  
  <p>So I have a group of pages, with random numbers as filenames ("05.html", "12.html" etc.), and I would like to create some sort of index page, using PHP to:</p>
  
  <ul>
  <li>fetch (I hope I'm using the term correctly) all the pages in the group, </li>
  <li>fetch, inside the pages, the content of a particular div; let's say, the source for an image (div id="pic")</li>
  <li>then display all the fetched contents to have a large list of pictures, along with relevant filenames and links to each page.</li>
  </ul>
  
  <p>So the index page would look something like this:</p>
  
  <pre><code>&lt;div class="pages"&gt;
    &lt;a href="[PAGENUMBER1].html"&gt;
      &lt;img src="[IMG SRC FROM THIS PAGE]"&gt;
      &lt;h2&gt;[FILENAME]&lt;/h2&gt;
    &lt;/a&gt;
  &lt;/div&gt;
  
  &lt;div class="pages"&gt;
    &lt;a href="[PAGENUMBER2].html"&gt;
      &lt;img src="[IMG SRC FROM THAT PAGE]"&gt;
      &lt;h2&gt;[FILENAME]&lt;/h2&gt;
    &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Edit:
  @ProEvilz Thank you. A typical page from the "random" pages would look like this:</p>
  
  <pre><code>&lt;body&gt;
    &lt;div id="image"&gt;
      &lt;img src="img/image.jpg"&gt;
    &lt;/div&gt;
    &lt;div id="title"&gt;
      &lt;h1&gt;Title&lt;/h1&gt;
    &lt;/div&gt;
    &lt;div id="caption"&gt;
      Here is the caption 
    &lt;/div&gt;
    &lt;div id="footer"&gt;
      &lt;a href="information"&gt;Information&lt;/a&gt;
    &lt;/div&gt;
  &lt;/body&gt; 
  </code></pre>