PHP数组作为数组键 [英] PHP array as array key
问题描述
是否有可能在php中将数组也设为数组键?
Is it possible in php to make an array an array key as well?
示例:
array(
array('sample', 'abc') => 'sample value'
);
推荐答案
否,如果您阅读了手册
一个数组在PHP中实际上是一个有序映射。映射是一种将值与键相关联的类型。该类型针对多种不同用途进行了优化。它可以被视为数组,列表(向量),哈希表(地图的实现),字典,集合,堆栈,队列等等。因为数组值可以是其他数组,所以树和多维数组也是可能的。
An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible.
And:
密钥可以是整数或字符串。该值可以是任何类型。
The key can either be an integer or a string. The value can be of any type.
这篇关于PHP数组作为数组键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!