note 77642 deleted from language.types.array by peehaa
| From: | peehaa@php.net | Date: | Sun, 28 Apr 2019 10:23:19 +0000 |
| Subject: | note 77642 deleted from language.types.array by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210771@lists.php.net to get a copy of this message | ||
Note Submitter: carl at linkleaf dot com
----
Its worth noting that there does not appear to be any functional limitations on the length or
content of string indexes. The string indexes for your arrays can contain any characters, including
new line characters, and can be of any length:
<?php
$key = "XXXXX";
$test = array($key => "test5");
for ($x = 0; $x < 500; $x++) {
$key .= "X";
$value = "test" . strlen($key);
$test[$key] = $value;
}
echo "<pre>";
print_r($test);
echo "</pre>";
?>
Keep in mind that using extremely long array indexes is not a good practice and could cost you lots
of extra CPU time. However, if you have to use a long string as an array index you won't have
to worry about the length or content.