I am generating associative arrays and the key value is a string concat of 1..n columns.
Is there a max length for keys that will come back to bite me? If so, I'll probably stop and do it differently.
There is no max on the limit of an array. There is a limit on the amount of memory your script can use. This can be changed in the 'memory_limit' in your php.
The array_keys() is a built-in function in PHP and is used to return either all the keys of and array or the subset of the keys. Syntax: array array_keys($input_array, $search_value, $strict)
Create an Array in PHP In PHP, there are three types of arrays: Indexed arrays - Arrays with a numeric index. Associative arrays - Arrays with named keys. Multidimensional arrays - Arrays containing one or more arrays.
The key() function is an inbuilt function in PHP which is used to return the index of the element of a given array to which the internal pointer is currently pointing.
It seems to be limited only by the script's memory limit.
A quick test got me a key of 128mb no problem:
ini_set('memory_limit', '1024M'); $key = str_repeat('x', 1024 * 1024 * 128); $foo = array($key => $key); echo strlen(key($foo)) . "<br>"; echo strlen($foo[$key]) . "<br>";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With