Array split processing (integer processing)
Known quantity Group A:
Array (
Array (
' Po_num ' = ' 20131227-000008102 ',
' Plant ' = ' jqsp ',
' Get_date ' = ' 2013-12-27 ',
' Cust_no ' = ' 12654172 ',
' Total ' = ' 225 ',
' SNP ' = ' 15 ',
' Mount ' = ' 15 ',
' Lp_no ' = ' p000000d ',
),
)
The handlers are as follows:
$t = 225;
$k = 0;
foreach ($a as $v) {
$t 1 = $v [' Total '];
$v [' total '] = $t 1 $t;
$res [$k] = $v;
$t 1-= $v [' Total '];
while ($t 1 >= $t) {
$v [' total '] = $t;
$t 1-= $t;
$res [+ + $k] = $v;
}
}
$res = Array_reverse ($res);
Print_r ($res);
The results obtained:
Array
(
[0] = = Array
(
[0] = = Array
(
[Po_num] = 20131227-000008102
[Plant] = JQSP
[Get_date] = 2013-12-27
[Cust_no] = 12654172
[Total] = 225
[SNP] = 15
[Mount] = 15
[Lp_no] = p000000d
)
)
[1] = = Array
(
[0] = = Array
(
[Po_num] = 20131227-000008102
[Plant] = JQSP
[Get_date] = 2013-12-27
[Cust_no] = 12654172
[Total] = 0//Generates 0 items
[SNP] = 15
[Mount] = 15
[Lp_no] = p000000d
)
)
)
Since it is divisible, then the result should be only one, how to modify the code so that it is not 0-item generation?
Share to: more
------Solution--------------------
This post was last edited by xuzuning on 2013-12-27 15:34:48
$a = Array (
Array (
' Po_num ' = ' 20131227-000008102 ',