0

我有一个像下面这样的多维数组

var myarray = new Array();
myarray["firstkey"] = new Array();
myarray["firstkey"]["secondkey"] = new Array();
myarray["firstkey"]["secondkey"]["0"] = new Array();
myarray["firstkey"]["secondkey"]["0"]["a"] = 100;
myarray["firstkey"]["secondkey"]["0"]["b"] = 1200;
myarray["firstkey"]["secondkey"]["0"]["c"] = 32000;
myarray["firstkey"]["secondkey"]["0"]["d"] = 23001;
myarray["firstkey"]["secondkey"]["0"]["e"] = "text";
myarray["firstkey"]["secondkey"]["0"]["f"] = "text";
myarray["firstkey"]["secondkey"]["0"]["g"] = "text";
myarray["firstkey"]["secondkey"]["0"]["h"] = "";
myarray["firstkey"]["secondkey"]["0"]["i"] = 0;
myarray["firstkey"]["secondkey"]["0"]["aa"] = new Array();
myarray["firstkey"]["secondkey"]["0"]["bb"]["bbb"] = 16;
myarray["firstkey"]["secondkey"]["0"]["cc"]["ccc"] = "text";
myarray["firstkey"]["secondkey"]["0"]["dd"]["ddd"] = new Array();
myarray["firstkey"]["secondkey"]["0"]["ee"]["eee"]["0"] = "text";
myarray["firstkey"]["secondkey"]["0"]["ff"]["fff"]["1"] = "text";`

我想从 PHP 中获取它,但我找不到解决方案。谁能告诉我解决方案。我们将不胜感激。

4

2 回答 2

0

也许您可以尝试发送 JSON?

你应该从 PHP 中读取它:

$json = file_get_contents("php://input");
于 2013-04-28T18:11:50.600 回答
0

你可以做AJAX

JavaScript:

var array = JSON.stringify(myarray);
$.ajax({
    url: "/myphp/file.php",
    data: {array: array},
    dataType: "json",
    success: function(data){
        alert(data["return"]);
    }
});

PHP:

$array = json_decode($_POST["array"]);
$savedVal = $array["firstkey"]["secondkey"]["0"]["a"];
echo json_encode(array("return" => $savedVal));
于 2013-04-28T18:15:53.570 回答