foreach ($a as $k = + $v) {print_r ($newarr); echo $a [$k] [' 5 ']. '
';}
Array ( [0] = = Array ( [Lotno] = 3206 [Count] = + ) [1] = = Array ( [ Lotno] = 3207 [Count] [ 2] = = Array ( [Lotno] = 3218 [count] = 180< c14/>)) 120Array ( [0] = = Array ( [Lotno] = 3206 [Count] = [ 1] = = Array ( [Lotno] = 3207 [count] [2] = = Array ( [Lotno] = 3218 [Count] = 135
The count is added and if the result of the corresponding row is 120, the 3206*12 3207*63 is displayed 3218*45
If the result of the corresponding row is 135, the 3218*135 is displayed (135=180-45 (last count used 45), not enough)
Reply to discussion (solution)
Do not understand what you mean, 45 is written dead or calculated? Stick to your final result.
Figure it out. 45 = 120-12-63.
The results are similar to the following:
Items corresponding to Quantity
120 3206*12 3207*63 3208*45
135 3208*135 (135 = 180-45 (previous result set))
This means
$ar = Array (' Lotno ' + 3206, ' count ' = =), array (' lotno ' = = 3207, ' count ' = +), array (' Lotno ' =& Gt 3218, ' count ' = +), $s = '; $n = 0;foreach ($ar as $r) { if ($n + $r [' count '] >) { echo $s. $r [' Lotn O ']. '*' . (120-$n). " \ n "; echo $r [' Lotno ']. '*' . ($n = $r [' Count ']-(120-$n)). " \ n "; $s = '; } else { $s. = "$r [lotno]* $r [Count]"; $n + = $r [' count ']; if ($n = =) { echo "$s \ n"; $s = "; $n = 0;}}}
3206*12 3207*63 3218*45
3218*135
$ar = Array ( ' lotno ' + 3206, ' count ' = +), array (' lotno ' = = 3207, ' count ' = +), ar Ray (' lotno ' = 3218, ' count ' = +), $a =array ( array (' 5 ' =>120), Array (' 5 ' =>135)); foreach ($a as $k = $v) { echo $v [' 5 ']. " "; if ($v [' 5 ']==120) { $c =0; foreach (Array_slice ($ar, 0,-1) as $VL) { $c + = $VL [' count ']; echo $VL [' Lotno ']. " * ". $VL [' Count ']." ";} $end =end ($ar); Echo $end [' Lotno ']. " *" . ($sub = $v [' 5 ']-$c). '
';} else if ($v [' 5 ']==135) { echo $end [' Lotno ']. " *" . ($end [' count ']-$sub);}}