Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php到json不会传递所有数组(或者json不会显示所有接收到的值)_Php_Json - Fatal编程技术网

Php到json不会传递所有数组(或者json不会显示所有接收到的值)

Php到json不会传递所有数组(或者json不会显示所有接收到的值),php,json,Php,Json,如第一行和第三行所示,所有字段均已填充,第二行的某些字段保留为空白 填充值 $.post("__php_file.php", { 'number_of_input_row': number_of_input_row, 'date_day': date_day, 'date_month': date_month, 'date_year': date_year, 'currency': currency }, function(data, success) { $('#currency_load1

如第一行和第三行所示,所有字段均已填充,第二行的某些字段保留为空白

填充值

$.post("__php_file.php", { 'number_of_input_row': number_of_input_row, 'date_day': date_day, 'date_month': date_month, 'date_year': date_year, 'currency': currency }, function(data, success) {

$('#currency_load1').html(data[0].FinalCurrencyRate);
$('#currency_load2').html(data[1].FinalCurrencyRate);
$('#currency_load3').html(data[2].FinalCurrencyRate);

}, "json");
发送到php文件,处理并获取这样的php数组

Array
(
    [0] => Array
        (
            [CurrencyAbbreviation] => AUD
            [DateOfCurrencyRate] => 2013-07-11
            [NumberOfInputRow] => 1
            [FinalCurrencyRate] => 0.506
        )

    [2] => Array
        (
            [CurrencyAbbreviation] => CAD
            [DateOfCurrencyRate] => 2013-07-25
            [NumberOfInputRow] => 3
            [FinalCurrencyRate] => 0.516
        )

)
json数组是这样的吗

{
"0":{"CurrencyAbbreviation":"AUD","DateOfCurrencyRate":"2013-07-11","NumberOfInputRow":"1","FinalCurrencyRate":"0.506"},
"2":{"CurrencyAbbreviation":"CAD","DateOfCurrencyRate":"2013-07-25","NumberOfInputRow":"3","FinalCurrencyRate":"0.516"}
}
到目前为止一切正常。但下面描述的是问题

返回结果并在此处显示

<div id="currency_load1"></div>
<div id="currency_load2"></div>
<div id="currency_load3"></div>

一切都好。正如在
jquery
中所理解的,需要创建类似
的条件,如果FinalCurrencyRate为空,则$('currency_load2').html(“0”)?但是为什么会出现这种json/jquery行为呢?

您的php数组缺少一个元素。请尝试
data['2']
。仅供参考,数字对象键是TerribleTreated
$('currency_load3').html(数据['2'])什么也看不见…@DevZer0,请问缺少什么元素?没有货币的行不在您的数据结构中
$('#currency_load1').html(data[0].FinalCurrencyRate);
$('#currency_load2').html("test to check");
$('#currency_load3').html(data[2].FinalCurrencyRate);