Skip to content

Instantly share code, notes, and snippets.

@srockstyle
Last active December 14, 2015 22:09
Show Gist options
  • Save srockstyle/5156767 to your computer and use it in GitHub Desktop.
Save srockstyle/5156767 to your computer and use it in GitHub Desktop.
なんか作ってといわれたのでつくってみた。スクリプトが配置されているディレクトリのHTMLの中のtitleタグの中身とファイル名をCSVで出力する。
<?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