我有一个JS脚本,我将代码转换为PHP,但我仍然坚持使用正确的语法来创建与PHP脚本中的这段代码相同的代码:
var sdata = {
"13":{
"22":["618","22","1","1","0","0","0"],
"21":["617","22","1","1","0","0","0"]
},
"14":{
"22":["619","22","1","1","0","0","0"],
"20":["622","22","1","1","0","0","0"]
},
"15":{
"20":["623","22","1","1","0","0","0"]
}
};
有什么想法吗?
答案 0 :(得分:2)
最简单的做法是确保你的确切是使用jQuery .get函数,将此数组作为数据的一部分发送,然后在$ _GET变量上运行PHP函数json_decode以获取PHP array :)如果你需要对它进行硬编码,你可以print_r数组。
答案 1 :(得分:2)
$sdata = array(
"13" => array(
"22" => array("618","22","1","1","0","0","0"),
"21" => array("617","22","1","1","0","0","0")
),
"14" => array(
"22" => array("619","22","1","1","0","0","0"),
"20" => array("622","22","1","1","0","0","0")
),
"15" => array(
"20" => array("623","22","1","1","0","0","0")
)
);
答案 2 :(得分:0)
答案 3 :(得分:0)
看起来你需要的是一个多维数组。由于您似乎是PHP的新手,请查看PHP中阵列手册页上的代码示例: http://php.net/manual/en/language.types.array.php