时间:2021-07-01 10:21:17 帮助过:16人阅读
array (
0 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12654172',
'total' => '615',
'snp' => '15',
'mount' => '41',
'lp_no' => 'P000000D',
),
1 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12647212',
'total' => '60',
'snp' => '15',
'mount' => '4',
'lp_no' => 'P000000D',
),
)
分享到:
array (
'po_num' => '1/7',//新增字段信息
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12654172',
'total' => '615',
'snp' => '15',
'mount' => '41',
'lp_no' => 'P000000D',
),
...
)
$ar = array (
0 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12654172',
'total' => '615',
'snp' => '15',
'mount' => '41',
'lp_no' => 'P000000D',
),
1 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12647212',
'total' => '60',
'snp' => '15',
'mount' => '4',
'lp_no' => 'P000000D',
),
);
$split_num = 100;
foreach($ar as $item) {
if($item['total'] <= $split_num) {
$res[] = $item;
continue;
}
$total = $item['total'];
$n = ceil($total/$split_num);
for($i=1; $i<$n; $i++) {
$res[] = array_merge(array('po_nume' => "$i/$n"), $item, array('total' => $split_num));
}
$res[] = array_merge(array('po_nume' => "$i/$n"), $item, array('total' => $total%$split_num));
}
print_r($res);
Array
(
[0] => Array
(
[po_nume] => 1/7
[po_num] => DYNP-770266110-00
[plant] => DYNP
[get_date] => 2013-09-09
[cust_no] => 12654172
[total] => 100
[snp] => 15
[mount] => 41
[lp_no] => P000000D
)
[1] => Array
(
[po_nume] => 2/7
[po_num] => DYNP-770266110-00