create large text file with 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)


$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 viewed 3809 times. First hit: 01-Nov-2015 23:48:52
Share email, Google+, Twitter, Facebook.
comments powered by Disqus