PHP Multidimensional Array Small doubt

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.