I want to read a file line by line, but without completely loading it in memory.
My file is too large to open in memory, and if try to do so I always get out of memo
Function to Read with array return
function read_file($filename = ''){ $buffer = array(); $source_file = fopen( $filename, "r" ) or die("Couldn't open $filename"); while (!feof($source_file)) { $buffer[] = fread($source_file, 4096); // use a buffer of 4KB } return $buffer; }