1. Go to this page and download the library: Download camoo/toc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
camoo / toc example snippets
$toc = new TableOfContents('<h1>Html Content</h1>');
// get only table of contents part
$onlyTableOfContents = $toc->getTableOfContents();
// get full content with table of contents
$htmlContent = <<<END
<h1>This is a header tag h1</h1>
<p>Lorum ipsum doler sit amet</p>
<h2>This is a header tag h2</h2>
<p>Foo Bar</p>
<h3>This is a header tag h3</h3>
END;
$toc = new TableOfContents($htmlContent);
$fullHtml = $toc->getContent();
echo $fullHtml;
$htmlContent = '<h1>Tester</h1><b>Bold</b><h2>Sub-Test</h2><a href="#">link</a><h3>3rd Level</h3><h4>4rd level</h4>';
// Get TOC using h1-h3
$toc = new TableOfContents($htmlContent,3);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.