BandonRandon BandonRandon - 30 days ago 7
PHP Question

Working with an array with periods in key values

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.

I have this array
[3.3] => First Name [3.6] => Last Name[2] => email@example.com
.

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?

Answer Source

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'];