Home Account

create large text file with php

2012-12-13 11:40 dennis iversen

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.

This page has been requested 4653 times