SplFixedArray when the array is large and the shape is known

A PHP array is a hash table even when the keys are 0 to n. That flexibility costs memory — roughly three times what a plain C array of the same length would need — which is invisible at a thousand elements and very visible at a million.

$plain = range(0, 1000000);
// ~ 33 MB

$fixed = SplFixedArray::fromArray(range(0, 1000000));
// ~ 8 MB

The trade is that the size is fixed at construction and the keys must be integers in range — writing past the end throws instead of growing. That makes it a poor general-purpose replacement and a good one for the specific case of a large numeric buffer whose length you know up front, such as a sieve or a fixed-size ring.