Maximum length for array key?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Maximum length for array key?

Post by seodevhead »

Hey guys... I am building an array that uses string indexes and wasn't sure if there is a MAX to the number of characters you can have in the index name of an array's element. Example:

Code: Select all

$zipCodes = array(
     'Saint Delmarca de Angelo of West Corpus Christie' => 39288
     'Le Tettelluna San Madrid in East Corpus Equadoria' => 38723
);
..or can I use as long a string as I want? It just looks wierd having the key be so long, but thought I'd ask to be on the safe side. Thanks.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Maximum length for array key?

Post by Mordred »

rtfm wrote:A key may be either an integer or a string.
rtfm wrote:Note: It is no problem for a string to become very large. There is no practical bound to the size of strings imposed by PHP, so there is no reason at all to worry about long strings.
Post Reply