php - How can I store a huge number of small values so that my RAM doesn't fill up? -


i looping through large number of possible combinations of person's position.

this example array:

[891532] => array     (         [0] => 1012         [1] => 5050         [2] => 1     ) 

the above says following: in iteration 891532, player's x position 1012, y position 5050 , rotation 1.

storing information array seems take lot more memory i'd expect. there way store information binary data, example?

something this, maybe?

[891532] => 0010120050501 

how in php?

you can use elementary compression.

log2(10000) = 13.28, need 2*14+1=29 bits, nicely fits single 32 bit integer.

$comp = $first + 16384*$second + 16384*16384*$third 

Comments