PHP关联数组的键(索引)限制? [英] PHP associative array's keys (indexes) limitations?
问题描述
如果有一些在PHP中数组的键限制?长度 ?不能接受的字符串?
在href=\"http://www.php.net/manual/en/language.types.array.php\" rel=\"nofollow\">官方文档的的发现不仅如此,但也有没有关于键限制的信息。
一个键可以是整数或字符串。如果一个密钥是一个整数的标准重新presentation,这将是PTED如(例如8将PTED 8间$ P $间$ P $,而08,将除preTED为08)。在关键的花车被截断为整数。索引和关联数组类型在PHP相同的类型,它可以同时包含整型和字符串指数。*
块引用>解决方案此问题是几乎完全一样的。但是,如果你不想相信任何非官方的,只是坚持使用较少的小钥匙。你甚至可能会得到一些性能优势出来。
编辑:并为的PHP手动说:
请注意:这是一个字符串变得非常巨大也没有问题。 PHP规定了一个字符串的大小没有边界;唯一的限制是其PHP运行的计算机的可用内存。
块引用>If there are some kind of limitations for array keys in PHP ? Length ? Not acceptable strings ?
In the official documentation found only this, but there is no information about keys limitations.
A key may be either an integer or a string. If a key is the standard representation of an integer, it will be interpreted as such (i.e. "8" will be interpreted as 8, while "08" will be interpreted as "08"). Floats in key are truncated to integer. The indexed and associative array types are the same type in PHP, which can both contain integer and string indices.*
解决方案What is the max key size for an array in PHP?
This question is almost the exact same. But if you dont want to trust anything unofficial, just stick to using less small keys. You may even get some performance benefits out of it.
EDIT: And as the The PHP Manual says:
Note: 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..
这篇关于PHP关联数组的键(索引)限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!