In my PHP script I need to create an array of >600k integers. Unfortunately my webservers memory_limit
is set to 32M so when initializing the array the script a
You can try to use a SplFixedArray, it's faster and take less memory (the doc comment say ~30% less). Test here and here.
A PHP Judy Array will use significantly less memory than a standard PHP array, and an SplFixedArray.
I quote "An array with 1 million entries using regular PHP array data structure takes 200MB. SplFixedArray uses around 90 megabytes. Judy uses 8 megs. Tradeoff is in performance, Judy takes about double the time of regular php array implementation."