我有一个看起来像这样的数组POST
Array
(
[ponumber] => 111111
[man_part_number] => Array
(
[0] => 11C2555
[1] => 11C2555
[2] => 11C2555
[3] => 11C2555
)
[model] => Array
(
[0] => FORMS PRINTER 2500 SERIES
[1] => FORMS PRINTER 2500 SERIES
[2] => FORMS PRINTER 2500 SERIES
[3] => FORMS PRINTER 2500 SERIES
)
[damaged] => Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
)
[serial_number] => Array
(
[0] => CNCQ202070
[1] => CNCQ210800
[2] => MY5203B1KQ
[3] => CN1863Q0PQ
)
[skid] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
[submit] => Attach this serial number list to PO#111111
)
我需要将数组合并到
中Array
(
[man_part_number] => Array
(
[0] = > 11C2555
)
[model] => Array
(
[0] => FORMS PRINTER 2500 SERIES
)
[damaged] => Array
(
[0] => 0
)
[serial_number] => Array
(
[0] => CNCQ202070
)
[skid] => Array
(
[0] => 1
)
[ponumber] => Array
(
[0] => 111111
}
}
等等,所有[0]也被组合[1],[2]和[3],但是ponumber也需要添加到每个数组中,并且对于所有4都是相同的。< / p>
答案 0 :(得分:0)
$array = array_map('current', $array[0]);
答案 1 :(得分:0)
您可以使用MultipleIterator
$mi = new MultipleIterator(MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_ASSOC);
$mi->attachIterator(new ArrayIterator($data['man_part_number']),"man_part_number");
$mi->attachIterator(new ArrayIterator($data['model']),"model");
$mi->attachIterator(new ArrayIterator($data['damaged']),"damaged");
$mi->attachIterator(new ArrayIterator($data['serial_number']),"serial_number");
$mi->attachIterator(new ArrayIterator($data['skid']),"skid");
echo "<pre>";
foreach ($mi as $member) {
print_r($member);
}
Array
(
[man_part_number] => 11C2555
[model] => FORMS PRINTER 2500 SERIES
[damaged] => 0
[serial_number] => CNCQ202070
[skid] => 1
)
Array
(
[man_part_number] => 11C2555
[model] => FORMS PRINTER 2500 SERIES
[damaged] => 0
[serial_number] => CNCQ210800
[skid] => 2
)
Array
(
[man_part_number] => 11C2555
[model] => FORMS PRINTER 2500 SERIES
[damaged] => 0
[serial_number] => MY5203B1KQ
[skid] => 3
)
Array
(
[man_part_number] => 11C2555
[model] => FORMS PRINTER 2500 SERIES
[damaged] => 0
[serial_number] => CN1863Q0PQ
[skid] => 4
)