466c544b7f38398f058407a7734db75a2447658c
[m6w6/ext-http] / docs / examples / extract.php
1 <?php
2 /**
3 * extract examples from tutorial.txt
4 */
5
6 if (preg_match_all('/\n- ([^\n]+).*?(\<\?.+?\?\>)/s', file_get_contents($_SERVER['argv'][1]), $matches)) {
7 for ($i = 0; $i < count($matches[0]); $i++) {
8 file_put_contents(preg_replace('/\W/', '_', $matches[1][$i]).".php", $matches[2][$i]."\n");
9 }
10 }
11
12 ?>