$arr = array(array(array(array(array()))));
The above example shows an array with five dimensions.
Is there a maximum number of dimensions allowed in a PHP array? If so, what is that maximum?
Each array
level generally costs you 304
bytes (determined by checking memory usage, creating an array, then checking again), and the total amount of memory can be calculated using ini_get("memory_limit")
. To get the current usage, run memory_get_usage()
.
On my computer:
ini_get("memory_limit")
returns "128M"
, or 134217728
bytes. memory_get_usage()
base use is 627120
so I would expect the limit on my kit to be 439442
depth
It's about memory limit. Try it yourself.
$array = array();
$temp_array = &$array;
while (true)
$temp_array = &$temp_array[0];