I\'m writing a php script where I call
$lines = file(\'base_list.txt\');
to break a file up into an array. The file has over 100,000 lines in
Edit: As Rob said, if your application is running out of memory, chances are it won't even get to the print_r
line. That's kinda my hunch as well, but if it is a memory issue, the following might help.
Take a look in the php.ini file for this line, and perhaps increase it to 16 or more.
memory_limit = 8M
If you don't have access to php.ini (for example if this was happening on a shared server) you can fix it with a .htaccess
file like this
php_value memory_limit 16M
Apparently some hosts don't allow you to do this though.
Is it possible there is an inherent limit on the output from print_r. I'd suggest looking for the first and last line in the file to see if they are in the array. If you were hitting a memory limit inserting into the array you would never have gotten to the print_r line.
every time ive run out of memory in PHP i've received an error message stating that fact. So, I'd also say that if you're running out of memory then the script wouldn't get to the print_r()
try enabling auto_detect_line_endings
in php.ini or by using
ini_set('auto_detect_line_endings', 1)
. There may be some line endings that windows doesn't understand & this ini option could help. more info about this ini option can be found here
Two suggestions:
Count the actual number of items in the array and see whether or not the array is the correct number of entries (therefore eliminating or identifying print_r()
as the culprit)
Verify the input... any chance that the line endings in the file are causing a problem? For example, is there a mix of different types of line endings? See the manual page for file() and the note about the auto_detect_line_endings
setting as well, though it's unlikely this is related to mac line endings.
I believe it is based on the amount of available memory as set in the php.ini file.
If you're outputting to something like Internet Explorer, you might want to make sure it can display all the information you're trying to put there. I know there's a limit to an html page, but I'm not sure what it is.