Problems with PHP when trying to create big array

前端 未结 3 771
鱼传尺愫
鱼传尺愫 2020-12-28 19:17

Here is my code, which creates 2d array filled with zeros, array dimensions are (795,6942):

function zeros($rowCount, $colCount){
    $matrix = array();
             


        
3条回答
  •  太阳男子
    2020-12-28 19:40

    The default PHP array implementation is very memory-intensive. If you are just storing integers (and lots of them), you probably want to look at SplFixedArray. It uses a regular contiguous memory block to store the data, as opposed to the traditional hash structure.

提交回复
热议问题