PHP 中数组的最大键大小是多少? [英] What is the max key size for an array in PHP?

查看:34
本文介绍了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天全站免登陆