使用数组在键值时期 [英] Working with an array with periods in key values
本文介绍了使用数组在键值时期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是从一个数组中获取数据。出于某种原因,数组的键值如 [3.3]
这我无法从检索数据。
I'm getting data from an array. For some reason the array has key values like [3.3]
which I'm having trouble retrieving data from.
我有这样的阵列 [3.3] =>名字[3.6] =>姓[2] => email@example.com
。
当我尝试调用 $阵列[3.3]
返回null,但是当我打电话 $阵列[2]
我给出的电子邮件。任何想法?
When I try to call $array[3.3]
it returns null, but when I call $array[2]
I am given the e-mail. Any ideas?
推荐答案
使用单引号(基本上是把它当作一个字符串,这就是PHP是可能做)
Use single quotes when referencing the key value (basically treat it like a string, that's what PHP is probably doing)
echo $array['3.3'];
这篇关于使用数组在键值时期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文