Create a table of contents automatically.
Posted on 2003-11-14
Ok, here's what I want to do: my site has a ot of articles and they are all generally organized by h3 header tags for section headings (and I can clean it up to strictly enforce that). Now I am thinking that I want to add a TOC to the top of the article, in the sense of:
2. Blah Blah
3. More Blah Blah
Each one would be a link to an anchor in the article.
So I need to 1) parse the article and add anchor tags to the headings and 2) build a TOC. I have a good idea of how to do this in other languages, but I am still pretty new to PHP and I am sure I would miss built-in functions that would help a lot. Any suggestions?