我试图在Excel VBA中创建包含这样的数据的变量' php'
$classroom['group1']['sub_group1']['John']['math']['pretest'] = 20;
$classroom['group1']['sub_group1']['John']['math']['posttest'] = 50;
$classroom['group1']['sub_group1']['John']['science']['pretest'] = 26;
$classroom['group1']['sub_group1']['John']['science']['posttest'] = 45;
$classroom['group1']['sub_group1']['David']['math']['pretest'] = 40;
$classroom['group1']['sub_group1']['David']['math']['posttest'] = 44;
$classroom['group1']['sub_group1']['David']['science']['pretest'] = 15;
$classroom['group1']['sub_group1']['David']['science']['posttest'] = 17;
$classroom['group1']['sub_group2']['Kate']['math']['pretest'] = 15;
$classroom['group1']['sub_group2']['Kate']['math']['posttest'] = 30;
$classroom['group1']['sub_group2']['Kate']['science']['pretest'] = 26;
$classroom['group1']['sub_group2']['Kate']['science']['posttest'] = 40;
$classroom['group1']['sub_group2']['Alice']['math']['pretest'] = 14;
$classroom['group1']['sub_group2']['Alice']['math']['posttest'] = 35;
$classroom['group1']['sub_group2']['Alice']['science']['pretest'] = 28;
$classroom['group1']['sub_group2']['Alice']['science']['posttest'] = 42;
echo json_encode($classroom);
我希望它的结果应该是层状结构,如下图所示
我尝试使用字典,但我的数据有重复密钥。
我应该怎么做才能得到我想要的结果以及我应该使用什么样的变量类型?
谢谢。