我有一个多维数组,如下所示
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中获取它,但我找不到解决方案。任何人都可以告诉我解决方案。回应将受到高度赞赏。
答案 0 :(得分:0)
也许您可以尝试发送JSON?
你应该从PHP中读取它:
$json = file_get_contents("php://input");
答案 1 :(得分: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));