什么是PHP中的数组最大密钥大小? [英] What is the max key size for an array in PHP?

查看:160
本文介绍了什么是PHP中的数组最大密钥大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成关联数组和关键值是1..N列的字符串连接。

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.

推荐答案

这似乎是由脚本的内存限制的限制。

It seems to be limited only by the script's memory limit.

一个快速测试让我128MB的关键没有问题:

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>";

这篇关于什么是PHP中的数组最大密钥大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆