Reputation: 6092
I have a PHP-script that parses logfiles from my server. At the moment the data is written in an array and printed. Later, the data will be saved in an MySQL-Database.
The problem is, that the array with the is never larger than 1893, which is only a small part of the data. The number didn't change after I increased the memory_limit from 128M to 512M. I'm absolutely sure, that all logs are processed.
Is there a limit for arrays?
Or is there a problem with my code. Every log-file is parsed into an array ($result) which is appended to the final array ($allResults).
$allResults = $allResults+$result;
Upvotes: 0
Views: 129
Reputation: 116
There should not be a limit to the size of an array in PHP except for running out of memory.
I've not used that notation for appending arrays to each other and I don't think it does what you are trying to do. Have you tried you code with:
$allResults = array_merge($allResults, $result);
You may also just be having the script time out depending on the size of the files and the server load.
If you have not you could add this to the top of the page to see what the full errors are:
ini_set("display_errors", "1");
error_reporting(E_ALL);
Upvotes: 4
Reputation: 856
In php array, "+" operator is not as array_merge, You can refer to "+ operator in php". Here I recommend you use array_merge:
$allResults = array_merge($allResults,$result);
Upvotes: 1