数组:每个键存储多个值 [英] array: store multiple values per key

查看:95
本文介绍了数组:每个键存储多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经试图用相同的密钥添加两个值,但没有奏效。它推翻了旧值。是不是可以用相同的键添加多个值,并通过关键字进行检索时,我得到一个链接列表,我可以重复,以获取所有的值不同?

I once trying adding two values with the same key, but it didn't work. It overrode the old value. Isn't it possible to add more than one value with the same key, and when retrieving by key, I get a linked list which I can iterate to get all the different values?

推荐答案

除非你实际存储数组作为值。在PHP哈希表映射一个关键的有一个的值。该值可以是一个数组,但你必须自己建立数组。的你可以考虑创建一个类来为你做这个。

Not unless you actually store an array as the value. Hashtables in PHP map a key to one value. That value could be an array, but you have to build the array yourself. You might consider creating a class to do this for you.

这篇关于数组:每个键存储多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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