Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // в какой директории файлы
- $dir = 'test';
- $files0 = array();
- $files1 = scandir($dir);
- echo "<pre>";
- //var_dump($files1);
- echo "</pre>";
- $CountFiles1 = count($files1);
- for ($i = 0; $i < $CountFiles1; $i++) {
- $htm = preg_match('/\.html$/', $files1[$i]);
- if($htm == 0){unset($files1[$i]);}
- }
- sort($files1);
- $CountFiles2 = count($files1);
- $title = array();
- for ($i = 0; $i < $CountFiles2; $i++) {
- $filename = "$dir/$files1[$i]";
- $handle = fopen("$filename", "r");
- $contents = fread($handle, filesize($filename));
- $match_a = '/<title>(.+?)<\/title>/ism';
- $run_title = preg_match_all($match_a, $contents, $i_a);
- $i_a[1][0] .= "|<a href=\"http://{$_SERVER['HTTP_HOST']}/$filename\">$files1[$i]</a>";
- $title[] = $i_a[1][0];
- fclose($handle);
- $contents = null;
- }
- sort($title);
- $CountTitle = count($title);
- for ($i = 0; $i < $CountTitle; $i++) {
- $DoubleTitle = explode("|", $title[$i]);
- echo "$DoubleTitle[0] ";
- echo "$DoubleTitle[1]<br>";
- //echo "$title[$i]<br>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement