gpt4 book ai didi

javascript - 如何在php上调用数组数组

转载 作者:行者123 更新时间:2023-11-30 08:45:22 26 4
gpt4 key购买 nike

我想访问一个数组中的数据,我用 ajax 将其发送到 .php 页面。

发送前在函数中创建数组数组

var xi = new Array(maxests);
$(".mtable").find(".allownumericwithdecimal").each(function(){
var nth = ((i) % maxests) + 3
var alt = $(this).parent().parent().find("td:first").html()
var est = $('.mtable').find("thead tr:first td:nth-child("+nth+")").html()
var pay = $(this).val()

xi[i] = new Array(alt,est,pay);
i++;
})

php 输出:

Array(
[data] => Array
(
[name] =>
[description] =>
[project] => 1
[ae] => [["Alternativa 1","Estado N. 1","1"],["Alternativa 1","Estado N. 2","23"],["Alternativa 2","Estado N. 1","33"],["Alternativa 2","Estado N. 2","43"]]
))

我想访问 ae 中的数据。

echo $_POST['data']['ae'][0][0];

我正在尝试这个,但不是运气。我怎样才能得到每个值?

最佳答案

如果这是一个 var_dump($_POST)print_r($_POST),那么这个

[ae] => [["Alternativa 1","Estado N. 1","1"],["Alternativa 1","Estado N. 2","23"],["Alternativa 2","Estado N. 1","33"],["Alternativa 2","Estado N. 2","43"]]

是一个字符串

$ae=json_decode($_POST['data']['ae']);

echo $ae[0][0]; // what you thought $_POST['data']['ae'][0][0]; would do

foreach ($ae as $a){
print_r($a);
}

http://uk1.php.net/json_decode

关于javascript - 如何在php上调用数组数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22439678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com