How to make a large array (26000 x 26000) using PHP?

I am trying to create an array with PHP. The size of the array is 26000 x 26000. Is it possible to make the array so large? I'm already trying to create an array of size 10000 x 10000, but the program continues to tell me about it:

Fatal error: Out of memory (1886388224 allocated) (tried to allocate 24 bytes) in C: \ xampp \ htdocs \ matrix \ index.php on line 24

I have 8GB RAM, I already set memory_limit in php.ini with -1 (apache configuration). The code for assembling the array is as follows:

function zeros($rowCount, $colCount) { $matrix = array(); for ($rowIndx=0; $rowIndx<$rowCount; $rowIndx++) { $matrix[] = array(); for($colIndx=0; $colIndx<$colCount; $colIndx++) { $matrix[$rowIndx][$colIndx]=0; } var_dump(memory_get_usage()); } return $matrix; } $matrix = zeros(25000,25000); 

I am also already trying to use SplFixedArray, but the result is the same. Please help me, thanks! :)

+5
source share
1 answer

You can also use this piece of code.

  $mon = range(1, 26000); for($i=0;$i<=25999;$i++){ $mon[$i] = range(1, 26000); } 
-1
source

Source: https://habr.com/ru/post/1247870/


All Articles