请查看我的DEMO并回答我的问题:为什么偏移2的值html中的日期不是日期而是数字?
DEMO: http://codepad.viper-7.com/r9FYnb
$data = array();
$data_1 = $_POST['data_1'];
$static = $_POST["static"];
foreach($static as $idx=>$val){
$data[] = array(
'data_1' => json_encode(Array($data_1[$idx*2],$data_1[$idx]*2+1)),
'static' => $static[$idx]
);
}
这是输出:
Array
(
[0] => Array
(
[data_1] => ["2011\/8\/02",4023] **//4023 !?**
[static] => 12
)
[1] => Array
(
[data_1] => ["2011\/8\/09",4023] **// 4023!?**
[static] => 34
)
[2] => Array
(
[data_1] => ["2011\/8\/16",4023] **// 4023 !?**
[static] => 56
)
)
答案 0 :(得分:3)
我不确定你在这里要做什么,但我发现你操纵$idx
'data_1' => json_encode(Array($data_1[$idx*2],$data_1[$idx]*2+1)),
// -----^^^^^^^^-------^^^^^^^^^^^^
对于第二个偏移量,您可能打算修改$idx
[]
'data_1' => json_encode(Array($data_1[$idx*2],$data_1[($idx*2)+1])),
// ---------------------^^^^^^^^^^^^
修改演示后的示例输出:
Array
(
[0] => Array
(
[data_1] => ["2011\/8\/02","2011\/8\/08"]
[static] => 12
)
[1] => Array
(
[data_1] => ["2011\/8\/09","2011\/8\/15"]
[static] => 34
)