这是我要处理的数组。
尝试数组([0] =>数组([checklist_id] => 3 [order_id] => [id] => 1) [1] =>数组([checklist_id] => 4 [order_id] => [id] => 2)[2] => 数组([checklist_id] => 7 [order_id] => 8,9,10,11,12 [id] => 4));
array_push
后
$alreadyassingorder=array();
foreach ($collection as $checklistorder) {
if($checklistorder['order_id'])
{
$order=explode(',', $checklistorder['order_id']);
array_push($alreadyassingorder,$order);
}
}
输出
数组([0] =>数组([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7)[1] =>阵列([0] => 8 [1] => 9 [2] => 10 [3] => 11 [4] => 12))
我想要的输出
数组([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7)[7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12))
答案 0 :(得分:1)
试试这样:
$alreadyassingorder=array();
foreach ($collection as $checklistorder) {
if($checklistorder['order_id'])
{
$order=explode(',', $checklistorder['order_id']);
foreach($order as $index=>$key):
array_push($alreadyassingorder,$key);
endforeach;
}
}