Php multi-dimensional array problem $ families & nbsp ;=& nbsp; array (& nbsp; "Griffin in" = & gt; array & nbsp; (& nbsp; & nbsp; "Peter", & nbsp; "Lois", small issues with php multi-dimensional array
$families = array
(
"Griffin"=>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire"=>array
(
"Glenn"
),
"Brown"=>array
(
"Cleveland",
"Loretta",
"Junior"
)
);
If an element is printed normally, it is written in this way.
$ Families [Griffin in] [0],
But I have seen it.
$ Families [Griffin [0],
What is the difference? where are they used?
------ Solution --------------------
// As mentioned on the #1 and #2 floors, there is indeed a problem with the second writing method for the example of the landlord.
// Modify the array if you really want a value.
$ Families = array
(
"Griffin in" => array
(
"Peter ",
"Lois ",
"Megan"
),
"Quagmire" => array
(
"Glenn"
),
"Brown" => array
(
"Cleveland ",
"Loretta ",
"Junior"
),
"Peter" => 9
);
$ Griffin in = array (
"Peter ",
"Lois ",
"Megan"
);
Print_r ($ families ['grip'] [0]);
Print_r ($ Griffin in [0]);
Print_r ($ families [$ Griffin in [0]);
------ Solution --------------------
// Retrieve the value of the "fmilies" array as [Griffin in] and [0]
$ Families [Griffin in] [0],
// Retrieve the value of the lower mark named fmilies array as [Griffin [0]
$ Families [Griffin [0],
The two statements have different meanings. the values in [] are the following table in the array.
The second method in this example is incorrect.
------ Solution --------------------
In 2nd, the meaning is not the same as that in the first method.