Art*_*cto 44
是的,元素的最大数量有限制.哈希表结构(数组基本上是哈希表的包装器)定义如下(PHP 5.3):
typedef struct _hashtable {
uint nTableSize;
uint nTableMask;
uint nNumOfElements;
ulong nNextFreeElement;
Bucket *pInternalPointer; /* Used for element traversal */
Bucket *pListHead;
Bucket *pListTail;
Bucket **arBuckets;
dtor_func_t pDestructor;
zend_bool persistent;
unsigned char nApplyCount;
zend_bool bApplyProtection;
#if ZEND_DEBUG
int inconsistent;
#endif
} HashTable;
Run Code Online (Sandbox Code Playgroud)
鉴于
typedef unsigned int uint;
Run Code Online (Sandbox Code Playgroud)
限制是unsigned int的最大大小(在32位操作系统和大多数64位操作系统上通常为2 ^ 32-1).
但实际上,除了具有大量RAM和32位整数的计算机之外,在此成为问题之前,您将始终达到内存限制.
我在参考php时遇到的唯一一件事是来自bytes.com/forum:
我不认为数组的大小有限,但是脚本可以使用多少内存是有限制的.
php.ini配置文件中的'memory_limit'指令保存脚本可以使用的最大内存量.尝试更改此项,看看是否有帮助.