PHP multi-dimensional array small problem
$families = array
(
"Griffin" =>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire" =>array
(
"Glenn"
),
"Brown" =>array
(
"Cleveland",
"Loretta",
"Junior"
)
);
Printing an element normally, that's what it says.
$families [Griffin][0],
But I've seen it written like this.
$families [Griffin[0]],
Excuse me, what's the difference?
------Solution--------------------
As the number four and the building of the example of the landlord, the second writing does have a problem
If you really want a value, try changing the array
$families = array
(
"Griffin" =>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire" =>array
(
"Glenn"
),
"Brown" =>array
(
"Cleveland",
"Loretta",
"Junior"
),
"Peter" =>9
);
$Griffin =array (
"Peter",
"Lois",
"Megan"
);
Print_r ($families [' Griffin '][0]);
Print_r ($Griffin [0]);
Print_r ($families [$Griffin [0]]);
------Solution--------------------
Remove the subscript value named Fmilies array as [griffin],[0]
$families [Griffin][0],
Remove the subscript value named Fmilies array as [griffin[0]]
$families [Griffin[0]],
The values in the two different meanings [] are the following table in the array
The second way of writing in this example is wrong.
------Solution--------------------
2nd, the meaning of play to the same as the first