dqpkea9486 2017-07-25 03:09
浏览 281

Excel VBA中的多维关联数组

I'm trying to create variable in Excel VBA that contain data like this in '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);

the result I want it to be should be heirarchy structure as the image below

enter image description here

I tried to use dictionary but my data have duplicated key.

What should I do in order to get the result I want it to be and what kind of variable type should I use?

Thank you.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧