PHP关联数组的键(索引)限制? [英] PHP associative array's keys (indexes) limitations?

查看:182
本文介绍了PHP关联数组的键(索引)限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有一些在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规定了一个字符串的大小没有边界;唯一的限制是其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屋!

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