Versio

inhoudsopgave-generator

Gesponsorde koppelingen

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?php
function create_toc($text) {
   preg_match_all('/<h1 id="(.*?)">(.*?)<\/h1>/si',$text,$matches);
   $list = '<ul>';
   for($i = 0;!empty($matches[1][$i]);$i++) {
        $list .= '<li><a href="#'.$matches[1][$i].'">'.$matches[2][$i].'</a></li>';
   }

   $list .= '</ul>';
   return $list;
}

?>