关于多维数组的一个有关问题
程序员文章站
2024-01-18 20:28:46
...
关于多维数组的一个问题,
这个老是不对啊,求解。
Parse error: syntax error, unexpected '[' in D:\program files\wamp\www\text.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
$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 '';';
print_r( $class );
echo '
?>
这个老是不对啊,求解。
Parse error: syntax error, unexpected '[' in D:\program files\wamp\www\text.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
相关文章
相关视频