About the multi-dimensional array,

Source: Internet
Author: User
About the multi-dimensional array,
  [["name"=>"zs","age"=>"10","sex"=>"nan"],["name"=>"ls","age"=>"11","sex"=>"nan"],["name"=>"ww","age"=>"12","sex"=>"nv"]], [["name"=>"zs","age"=>"10","sex"=>"nan"],["name"=>"ls","age"=>"11","sex"=>"nan"],["name"=>"ww","age"=>"12","sex"=>"nv"]], [["name"=>"zs","age"=>"10","sex"=>"nan"],["name"=>"ls","age"=>"11","sex"=>"nan"],["name"=>"ww","age"=>"12","sex"=>"nv"]]];echo '
';print_r( $class );echo '
';?>

This is always wrong. solve it.
Parse error: syntax error, unexpected '[' in D: \ program files \ wamp \ www \ text. php on line 3


Reply to discussion (solution)

What is your definition? Array? You should define it in this way.

$ Class = array ("group1" => (
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
),
(
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
),
(
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
)
));

What is your definition? Array? You should define it in this way.

$ Class = array ("group1" => (
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
),
(
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
),
(
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
)
));


Well, isn't it necessary to use [] as much as possible? The array in the book is not written either.

Your code requires php> = 5.4


What is your definition? Array? You should define it in this way.

$ Class = array ("group1" => (
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
),
(
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
),
(
("Name" => "zs", "age" => "10", "sex" => "nan "),
("Name" => "ls", "age" => "11", "sex" => "nan "),
("Name" => "ww", "age" => "12", "sex" => "nv ")
)
));


Well, isn't it necessary to use [] as much as possible? The array in the book is not written either.


Yes, but the same applies [].
$ Class ['group1'] [] = array ("name" => "zs", "age" => "10", "sex" => "nan ");
$ Class ['group1'] [] = array ("name" => "ls", "age" => "11", "sex" => "nan ");
$ Class ['group1'] [] = array ("name" => "ww", "age" => "12", "sex" => "nv ");
.
.
.

Your code requires php> = 5.4


Thank you, moderator.

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.