当所有数据通过
$_GET['组'],
$_GET['章节']
$_GET['文章']
与已设置的$laws[$group][$chapter][$article]多维数组不匹配?
我问是因为我打算在$laws 多维数组中一次回显一篇文章,如果不存在这样的数组构造,则会返回错误。
非常感谢!
<?php
session_start();
$laws = array(
"group1" => array(
"1" => array(
"1" => "This is article (1) in chapter (1) of (group1)",
"2" => "This is article (2) in chapter (1) of (group1)",
"3" => "This is article (3) in chapter (1) of (group1)",
),
"2" => array(
"1" => "This is article (1) in chapter (2) of (group1)",
"2" => "This is article (2) in chapter (2) of (group1)",
"3" => "This is article (3) in chapter (2) of (group1)",
),
),
"group2" => array(
"1" => array(
"1" => "This is article (1) in chapter (1) of (group2)",
"2" => "This is article (2) in chapter (1) of (group2)",
"3" => "This is article (3) in chapter (1) of (group2)",
),
"2" => array(
"1" => "This is article (1) in chapter (2) of (group2)",
"2" => "This is article (2) in chapter (2) of (group2)",
"3" => "This is article (3) in chapter (2) of (group2)",
),
)
);
$_SESSION['group'] = $_GET['group'];
$_SESSION['chapter'] = $_GET['chapter'];
$_SESSION['article'] = $_GET['article'];
$group = $_SESSION['group'];
$chapter = $_SESSION['chapter'];
$article = $_SESSION['article'];
// Echo Article from $laws multidimensional Array
echo $laws[$group][$chapter][$article];
?>