ページの見出しタグに基づいてネストされた目次を自動的に生成するためのエレガントな php コードのソリューションを教えてくれる狡猾なプログラマーは誰ですか?
したがって、次のようなhtmlドキュメントがあります。
<h1> Animals </h1>
Some content goes here.
Some content goes here.
<h2> Mammals </h2>
Some content goes here.
Some content goes here.
<h3> Terrestrial Mammals </h3>
Some content goes here.
Some content goes here.
<h3> Marine Mammals </h3>
Some content goes here.
Some content goes here.
<h4> Whales </h4>
Some content goes here.
Some content goes here.
より具体的には、同じページの見出しへのリンクのネストされたリストの形式で、リンクされた目次が必要です。
目次 (PHP コードによって自動的に生成されます)
- 動物
- 哺乳類
- 陸生_哺乳類
- 海洋哺乳類
- くじら
- 哺乳類