weixin_33730836 2016-10-18 06:31 采纳率: 0%
浏览 18

没有得到数组的确切值

my orginal output is

below

[status] => 1
[schedule_status] => 1
[cid] =>3
[cdate] => 16-10-18 01:10:52
[did] => 16
[jid] => 4

After i use seperate array value using

$count = count($_POST[user]);

if($count>=1) { 

    for($i=0;$i<$count;$i++) {

        $candi_id =array('cid'=>$_POST[user][cid][$i]);

        $scheduleUp = array('cid'=>$_POST[user][cid][$i],'jid'=>$_POST[data][jid][$i],'did'=>$_POST[data][did][$i]);
    }
}

iam getting did is 1 why?

  • 写回答

1条回答 默认 最新

  • larry*wei 2016-10-18 06:36
    关注

    You have single dimensional array. So why you try to fetch the data as loop? do not use $_POST[data][did][$i] please use as $_POST[data][did]

    What it will do is: $_POST[data][did] is return the result of 16 now from the string you are trying to access as array and fetch record for [$i] and starting of $i is 0 so it will return the 1st character from the string. If it is of 1 then it will return 6.

    So please try to remove [$i] from the end.

    评论

报告相同问题?