title: Creating a table of contents in php
body: <p>I am looking to create a very simple, very basic nested table of contents in php which gets all the h1-6 and indents things appropriately. This means that if I have something like:</p>
  
  <pre><code>&lt;h1&gt;content&lt;/h1&gt;
  &lt;h2&gt;more content&lt;/h2&gt;
  </code></pre>
  
  <p>I should get:</p>
  
  <pre><code>content
      more content.
  </code></pre>
  
  <p>I know it will be css that creates the indents, that's fine, but how do I create a table of contents with working links to the content on the page?</p>
  
  <p><strong>apparently</strong> its hard to grasp what I am asking for...</p>
  
  <p>I am asking for a function that reads an html document and pulls out all the h1-6 and makes a table of contents.</p>