Advertisement
zero50x

RS Вывод заголовков H1

May 11th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  5. <title></title>
  6. </head>
  7. <body>
  8.  
  9. <?php
  10. // <meta charset="utf-8" />
  11. error_reporting(E_ALL | E_STRICT);
  12. ini_set('display_errors', TRUE);
  13. ini_set('display_startup_errors', TRUE);
  14. header('Content-type: text/html; charset=windows-1251');
  15.  
  16. $g1 = microtime(true);
  17.  
  18. if (isset($_POST['add']) )
  19. {
  20.     echo "POST существует <br>";
  21.     $post_word = $_POST['text'];
  22.     echo "До замены: {$post_word} <br>";
  23.     $post_word = preg_replace("/\s/ism", "\s", $post_word);
  24.     echo "После замены: {$post_word} <br>";
  25. }
  26.  
  27. $url = "http://{$_SERVER['HTTP_HOST']}/p/"; // !!!!!!!!!!!!!!!!!
  28. $dir    = 'p';                              // !!!!!!!!!!!!!!!!!
  29. $files0 = array();
  30. $files1 = scandir($dir);
  31.  
  32. unset($files1[0]);
  33. unset($files1[1]);
  34.  
  35.  
  36. $result = array_merge($files0, $files1);
  37.  
  38.  
  39. //print_r($result);
  40.  
  41. $countfiles = count($files1);
  42. $numfiles = $countfiles-1;
  43. $countfiles = 100;
  44.  
  45. echo "Файлов (эл-в массива): $numfiles <br><br><br>\n\n\n";
  46.  
  47.  
  48. //$i = 0;
  49.  
  50. for ($i = 0; $i < $countfiles; $i++) {
  51. ############################# ИСХОДНЫЙ ФАЙЛ ##########################################
  52. $filename = "$dir/$result[$i]";
  53. $handle = fopen("$filename", "r");
  54. $contents = fread($handle, filesize($filename));
  55. //echo "$contents";
  56.  
  57. $match_a = '/<h1>(.+?)<\/h1>/ism';
  58. $run_title = preg_match_all($match_a, $contents, $i_a);
  59. //echo "<b>{$i_a[1][0]}</b> <br>";
  60.  
  61. echo " <br>\n";
  62. $num_i_a = count($i_a[1]);
  63.     for ($h1 = 0; $h1 < $num_i_a; $h1++) {
  64.         echo "{$i_a[1][$h1]} <br>\n";
  65.         //var_dump($i_a[1]);
  66.     }
  67.  
  68.  
  69.  
  70. fclose($handle);
  71.  
  72. $contents = null;
  73.  
  74. } //конец цикла одного файла
  75.  
  76. $g2 = microtime(true);
  77. $g3 = $g2 - $g1; // время генерации
  78. echo "\n<br>Время: ". $g3 ."<br>\n";
  79.  
  80. ?>
  81.  
  82. <form action="" method="POST">
  83.     <textarea name="text" cols="50"></textarea>
  84.     <button type="submit" name="add">Add</button>
  85. </form>
  86.  
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement