jjk2 Posted June 16, 2009 Share Posted June 16, 2009 i am using file() on a huge txt file which probably has close to a 300,00 rows of text it keeps throwing fatal error message. what to do ? Quote Link to comment Share on other sites More sharing options...
ldougherty Posted June 16, 2009 Share Posted June 16, 2009 Hello, This is your PHP memory as defined in your php.ini as memory_limit You will need to adjust this value to something larger if you wish to read this text file. Quote Link to comment Share on other sites More sharing options...
akitchin Posted June 16, 2009 Share Posted June 16, 2009 another option is to read the file chunk-wise using this function: file_get_contents() this reads the contents into a string, but you can split the string if you'd like. this allows you to specify an offset and a maximum length, so you can iterate through the file bit by bit. note that you may still run into timeout issues. Quote Link to comment Share on other sites More sharing options...
jjk2 Posted June 19, 2009 Author Share Posted June 19, 2009 i used this $handle = @fopen($dir, "r") or die ("failed opening dir file list...exiting"); if ($handle) { while (!feof($handle)) { $lines[] = fgets($handle, 4096); } fclose($handle); } however, i still get the same error message... Quote Link to comment Share on other sites More sharing options...
pkedpker Posted June 21, 2009 Share Posted June 21, 2009 what messages is it throwing u haven't explained much.. did u try editing the memory_limit like ldougherty said Quote Link to comment Share on other sites More sharing options...
jjk2 Posted June 22, 2009 Author Share Posted June 22, 2009 yes i have. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.