Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
172 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...