PHP split files into smaller parts (e.g. big to smaller files)
代碼:
<?PHP
$how_many_part_to_split = 10;
$lines = explode("\n", file_get_contents("1.bat"));
$per_file_line = count($lines) / $how_many_part_to_split;
$i = 0;
$j = 0;
$file_cnt = 1;
$str = '';
for ($i = 0; $i < count($lines); $i++)
{
$str .= $lines[$i]."\n";
$j++;
if ($j >= $per_file_line)
{
file_put_contents('bat-'.$file_cnt.'.bat', $str);
$str = '';
$j = 0;
$file_cnt++;
}
}
if ($j > 0 || strlen($str) > 10)
{
file_put_contents('bat-'.$file_cnt.'.bat', $str);
}
?>
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|