-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtableofcontents.inc
33 lines (28 loc) · 925 Bytes
/
tableofcontents.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
class Toc{
function __construct($id=null, $class=null, $numbers=True) {
$this->table = array();
$this->i = 1;
$this->numbers = $numbers;
}
function add($s) {
$this->table[$this->i] = '<a href="#t' . $this->i . '">' . $s . "</a>";
if ($this->numbers)
$r = $this->i . ' <a name="t' . $this->i . '">' . $s . "</a>";
else
$r = '<a name="t' . $this->i . '">' . $s . "</a>";
$this->i += 1;
return $r;
}
function ht_echo($numbersToc=True) {
//var_dump($this->table);
foreach ($this->table as $i => $s) {
if ($numbersToc)
echo $i . " " . $s . "<br>\n";
else
echo $s . "<br>\n";
}
return;
}
}
?>