Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
- <title></title>
- </head>
- <body>
- <?php
- // <meta charset="utf-8" />
- error_reporting(E_ALL | E_STRICT);
- ini_set('display_errors', TRUE);
- ini_set('display_startup_errors', TRUE);
- header('Content-type: text/html; charset=windows-1251');
- $g1 = microtime(true);
- if (isset($_POST['add']) )
- {
- echo "POST существует <br>";
- $post_word = $_POST['text'];
- echo "До замены: {$post_word} <br>";
- $post_word = preg_replace("/\s/ism", "\s", $post_word);
- echo "После замены: {$post_word} <br>";
- }
- $url = "http://{$_SERVER['HTTP_HOST']}/p/"; // !!!!!!!!!!!!!!!!!
- $dir = 'p'; // !!!!!!!!!!!!!!!!!
- $files0 = array();
- $files1 = scandir($dir);
- unset($files1[0]);
- unset($files1[1]);
- $result = array_merge($files0, $files1);
- //print_r($result);
- $countfiles = count($files1);
- $numfiles = $countfiles-1;
- $countfiles = 100;
- echo "Файлов (эл-в массива): $numfiles <br><br><br>\n\n\n";
- //$i = 0;
- for ($i = 0; $i < $countfiles; $i++) {
- ############################# ИСХОДНЫЙ ФАЙЛ ##########################################
- $filename = "$dir/$result[$i]";
- $handle = fopen("$filename", "r");
- $contents = fread($handle, filesize($filename));
- //echo "$contents";
- $match_a = '/<h1>(.+?)<\/h1>/ism';
- $run_title = preg_match_all($match_a, $contents, $i_a);
- //echo "<b>{$i_a[1][0]}</b> <br>";
- echo " <br>\n";
- $num_i_a = count($i_a[1]);
- for ($h1 = 0; $h1 < $num_i_a; $h1++) {
- echo "{$i_a[1][$h1]} <br>\n";
- //var_dump($i_a[1]);
- }
- fclose($handle);
- $contents = null;
- } //конец цикла одного файла
- $g2 = microtime(true);
- $g3 = $g2 - $g1; // время генерации
- echo "\n<br>Время: ". $g3 ."<br>\n";
- ?>
- <form action="" method="POST">
- <textarea name="text" cols="50"></textarea>
- <button type="submit" name="add">Add</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement