最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

关于多维数组的一个有关问题

来源:http://erdangjiade.com/topic/79783.html 你好,世界。 2017-10-04 21:03浏览(0)

关于多维数组的一个问题,
<?php

$class = [

"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"]
]
];
echo '<pre>';
print_r( $class );
echo '</pre>';

?>

这个老是不对啊,求解。
Parse error: syntax error, unexpected '[' in D:program fileswampwwwtext.php on line 3
------解决方案--------------------
你这个定义 的是什么?数组吗? 按你的思路应该这样定义。

$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")
)
)) ;

------解决方案--------------------
你的代码要求 php >= 5.4

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2