在我的第二个数组中,我有一些逗号分隔值,我将这些值分解并创建新数组。现在我正在尝试添加这两个数组:
(
[0] => Array
(
[0] => Array
(
[0] => 0
[1] => 0
[2] => 1
[3] => 0
)
[1] => Array
(
[0] => 1
[1] => 0
[2] => 0
[3] => 0
)
)
[1] => Array
(
[qid] => 1
[question] => here is the first question
[answer1] => ans1
[answer2] => ans2
[answer3] => ans3
[answer4] => ans4
[correct_answer] => 0,0,1,0
[creadted_date] => 2015-01-16
)
[2] => Array
(
[qid] => 2
[question] => here is the second ques
[answer1] => ans1
[answer2] => ans2
[answer3] => ans3
[answer4] => ans4
[correct_answer] => 1,0,0,0
[creadted_date] => 2015-01-16
)
)
像这样:
[1] => Array
(
[qid] => 1
[question] => here is the first question
[answer1] => ans1
[answer2] => ans2
[answer3] => ans3
[answer4] => ans4
[c1] => 0
[c2] => 0
[c3] => 1
[c4] => 0
[correct_answer] => 0,0,1,0
[creadted_date] => 2015-01-16
)
[2] => Array
(
[qid] => 1
[question] => here is the first question
[answer1] => ans1
[answer2] => ans2
[answer3] => ans3
[answer4] => ans4
[c1] => 0
[c2] => 0
[c3] => 1
[c4] => 0
[correct_answer] => 0,0,1,0
[creadted_date] => 2015-01-16
)
答案 0 :(得分:0)
array_merge()应该做这个工作 根据您的示例,这应该可以解决问题:
array_merge(array[1],array[0][0]);
array_merge(array[2],array[0][1]);
答案 1 :(得分:0)
你看过php函数array_merge
吗?http://php.net/manual/en/function.array-merge.php
另外,看一些关于如何获得这个多维数组的代码可能会有所帮助