简体   繁体   English

数组中的不同数据类型值

[英]Different datatype values in an array

Why php array allows different datatype to reside in an array as array should contains data of same datatype but that is not the case with php?为什么 php 数组允许不同的数据类型驻留在一个数组中,因为数组应该包含相同数据类型的数据,但 php 不是这种情况?

For example: - We can add ints, strings, floats, all of these in a single array.例如: - 我们可以在一个数组中添加整数、字符串、浮点数,所有这些。

An array in PHP is actually an ordered map. PHP 中的数组实际上是一个有序映射。 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.由于数组值可以是其他数组,树和多维数组也是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM