Created
January 26, 2015 13:27
-
-
Save HiroKws/7e189257925f17b7915e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// 行数とページ数概算 | |
$stdIn = file_get_contents('php://stdin'); | |
$stdIn = preg_replace('/^#{1,6} /m', "\n", $stdIn); | |
$stdIn = preg_replace('/@<.+>@/sU', 'CoMeNt', $stdIn); | |
$stdIn = preg_replace("/\nCoMeNt\n/s", '', $stdIn); | |
$stdIn = preg_replace('/CoMeNt/', '', $stdIn); | |
$lines = explode("\n", $stdIn); | |
$lineCount = 0; | |
$lineAveage = 22.5; | |
foreach ($lines as $line) { | |
$lineCount += (integer)floor(mb_strlen($line)/$lineAveage) + 1; | |
} | |
$totalLine = 41; // 1ページあたりの行数 | |
$colums = 2; // 段組数 | |
print "だいたい行数: ".$lineCount."\n"; | |
print "だいたいページ数: ".$lineCount/($totalLine*$colums)."\n"; | |
print "1ページ800文字だと:".(mb_strlen($stdIn)/800)."\n"; | |
print "1ページ1200文字だと:".(mb_strlen($stdIn)/1200)."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment