1

我有一个 JS 脚本,我将代码转换为 PHP,但我坚持正确的语法是在我的 PHP 脚本中创建与 JS 中的这段代码相同的代码:

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"]
     }
};

有任何想法吗?

4

4 回答 4

2

最简单的方法是使用 jQuery .get 函数,将此数组作为数据的一部分发送,然后在 $_GET 变量上运行 PHP 函数 json_decode 以获取 PHP 数组:)然后,如果需要对其进行硬编码,则可以 print_r 数组。

于 2012-05-07T21:02:50.623 回答
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")
     )
);
于 2012-05-07T21:04:03.923 回答
0

查看多维数组:

http://php.net/manual/en/language.types.array.php

于 2012-05-07T21:03:06.693 回答
0

看起来你需要的是一个多维数组。由于您似乎是 PHP 新手,请查看 PHP 数组手册页上的代码示例:http: //php.net/manual/en/language.types.array.php

于 2012-05-07T21:03:28.660 回答