Home Account

create large text file with php

13-Dec-2012 11:40:46 dennis

Tags: php

In order to test something with a large text file, I had to create a large text file - larger than 1GB.

I started with a access.log file from apache that was approxamately 100MB (access.log)

<?php

$content = file_get_contents('access.log');
for ($i = 0; $i< 10; $i++ ) {
    file_put_contents('test.log', $content, FILE_APPEND | LOCK_EX);
}

This is a pretty fast way to create a very big file.