是否有大小限制到PHP数组键?什么是一般限制PHP数组? [英] Are there size limits to PHP array keys? What are the limits in general for PHP arrays?

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

问题描述


  

可能重复:结果
  什么是数组中的最大密钥大小PHP?


正如标题所说,我想知道什么是限制PHP的数组?


  1. 什么是极限,以数组键?

  2. 我可以使用任意大小的字符串作为重点?

  3. 在将钥匙启动点什么碰撞?
    我的意思是在这里,我想PHP数组是哈希表。我的哈希表和哈希函数的理解是,在某些时候两个字符串可以散列为相同的值,给你一个碰撞。例如MD5被发现没有抗碰撞。

  4. 什么是大小限制到一个PHP数组?


解决方案

  1. 什么是限制数组键?

    有没有理论极限那么多的内存分配给脚本的大小。您还可以找到一个证明在什么马克斯在PHP中的数组密钥大小?

    PHP手册中说 href=\"http://us.php.net/manual/en/language.types.string.php\">;


      

    请注意:这是一个字符串变得非常巨大也没有问题。 PHP规定了一个字符串的大小没有边界;唯一的限制是其PHP运行的计算机的可用内存。


    这一点很重要,因为一个数组中的键可以是字符串。


  2. 我可以使用任意大小的字符串作为重点?

    是的,这取决于分配给脚本的内存量。 的内存这套量一千兆字节,您可以通过启动您脚本,例如的ini_set('memory_limit的','1024M')设置大小。要设置内存限制无限制使用 1

    的时候按键的大小增长将需要更多的权力与阵列工作。


  3. 在什么时候会开始键碰撞?

    (我不知道现在如果我understod问题属性)如果你使用的字母和数字的所有组合到一个无限长的字符串,将有组合的无限的数字。并为此他们将永远不会发生碰撞。


  4. 什么是大小限制到一个PHP数组?

    它以相同的方式如上述限定,通过分配用于脚本的内存量


Possible Duplicate:
What is the max key size for an array in PHP?

As the title says, I'm wondering what are the limits to PHP's arrays?

  1. What are the limits to array keys?
  2. Can I use any size string as the key?
  3. At what point will keys start to collide? What I mean here is, I thought PHP arrays were hashtables. My understanding of hashtables and their hash functions are that at some point two strings can hash to the same value, giving you a collision. For example MD5 was found to not be collision resistant.
  4. What is the size limit to a php array?

解决方案

  1. What are the limits to array keys?

    There is no theoretical limits more then the size of memory allocated to the script. You can also find a proof at What is the max key size for an array in PHP?

    The php manual says here;

    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.

    This matters since the keys in a array can be strings.

  2. Can I use any size string as the key?

    Yes, depending on the amount of memory allocated for the script. You can set the size by starting you script with for example ini_set('memory_limit', '1024M'); this set amount of memory to one gigabyte. To set the memory limit to unlimited use -1.

    BUT when the size of the keys grows you will need more power to work with the array.

  3. At what point will keys start to collide?

    (I do not now if I understod the questions property)If you use all the combinations of letters and numbers up to a infinity long string, there will be infinity numbers of combinations. And therefor they will never collide.

  4. What is the size limit to a php array?

    It is limited in the same way as above, by the amount of memory allocated for the script.

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

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