array keys
by Guna[ Edit ] 2012-12-24 18:22:21
What is the maximum keys length for arrays in php?
A quick test got me a key of 128mb no problem:
ini_set('memory_limit', '1024M');
$key = str_repeat('x', 1024 * 1024 * 12
;
$foo = array($key => $key);
echo strlen(key($foo)) . "
";
echo strlen($foo[$key]) . "
";
As per PHP manual:
It is no problem for a string to become very large. PHP imposes no boundary on the size of a string; the only limit is the available memory of the computer on which PHP is running.