I am C++ programmer and trying my hand in PHP and found it is quite similar. I am trying to read a big source file using following code.
$filename = "sample.txt"; /* Having millions of records*/
$file_handle = fopen($filename, "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
/* do some parsing on $line*/
}
fclose($file_handle);
But i found when number of records in input file is more than 1 million it crahes and there is no output. How can i fix or optimize the code?