Last active
December 14, 2015 22:09
-
-
Save srockstyle/5156767 to your computer and use it in GitHub Desktop.
なんか作ってといわれたのでつくってみた。スクリプトが配置されているディレクトリのHTMLの中のtitleタグの中身とファイル名をCSVで出力する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = `ls *.html`; | |
$filelist = preg_split("/\n/",$output); | |
foreach($filelist as $file){ | |
if(empty($file)){ | |
continue; | |
} | |
$fp = fopen($file, "r"); | |
while ($line = fgets($fp)) { | |
if(preg_match("/\<title\>/",$line)){ | |
$line = strip_tags($line); | |
$line = ereg_replace("^(\s|\t)+","",$line); | |
$line = rtrim($line); | |
echo $line.",".$file."\n"; | |
}else{ | |
continue; | |
} | |
} | |
fclose($fp); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment