Share Pastebin
Guest
Public paste!

jeff_

By: a guest | Jun 16th, 2009 | Syntax: PHP | Size: 0.75 KB | Hits: 89 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. $page = file_get_contents('charron.html');
  2. // ici nettoyage du code pour ne garder que ce qui est entre les balises "body"
  3. preg_match_all('#<h([2])[^>]{0,}>(.*)</h\1>#i',$page,$match);
  4. $match = $match[0];
  5. $summary = array();
  6. foreach ($match as $m) {
  7.     $page = str_replace($m,'<!-- cut here -->'.$m,$theContent); // on place un marqueur de découpe
  8.     $summary[] = strip_tags($m); // on stocke les titres pour créer une page index
  9. }
  10. $page = explode('<!-- cut here -->',$page);
  11.  
  12. foreach ($page as $num=>$chunk) {
  13.     file_put_contents($num.'.html',$chunk);
  14. }
  15. $index = '';
  16.  
  17. foreach ($summary as $num=>$entry) {
  18.         $index = '<li><a href="'.$num.'.html">'.$entry.'</a></li>';
  19. }
  20. $index = '<ul>'.$index.'</ul>';
  21.  
  22. file_put_contents('index.html',$index);