-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
28 lines (19 loc) · 775 Bytes
/
test.php
File metadata and controls
28 lines (19 loc) · 775 Bytes
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
<?php
use \diversen\markdownSplit;
include_once "markdownSplit.php";
// You wont need the above include_once statement if
// you have proper autoloading setup
$text = file_get_contents('README.md');
$s = new \diversen\markdownSplit();
// Split by header level 1
// @text => a markdown text
// @setext => use both setext and atx headers
// @level => the header-level which will attach a new array
$res = $s->splitMarkdownAtLevel($text, $setext = true, $level = 1);
print_r($res);
// Or split by header-level 2, which means that both level 1 and level 2 headers
// will be placed as array values
$res = $s->splitMarkdownAtLevel($text, true, 2);
print_r($res);
// `Notice` $ret[0] is always any text that may be `before the first header`
// This is normally empty.