时间:2021-07-01 10:21:17 帮助过:7人阅读
foreach($a as $k=>$v)
{
print_r($newarr);
echo $a[$k]['5'].'
';
}
Array
(
[0] => Array
(
[lotno] => 3206
[count] => 12
)
[1] => Array
(
[lotno] => 3207
[count] => 63
)
[2] => Array
(
[lotno] => 3218
[count] => 180
)
)
120
Array
(
[0] => Array
(
[lotno] => 3206
[count] => 12
)
[1] => Array
(
[lotno] => 3207
[count] => 63
)
[2] => Array
(
[lotno] => 3218
[count] => 180
)
)
135
$ar = array (
array( 'lotno' => 3206, 'count' => 12 ),
array( 'lotno' => 3207, 'count' => 63 ),
array( 'lotno' => 3218, 'count' => 180 ),
);
$s = '';
$n = 0;
foreach($ar as $r) {
if($n + $r['count'] > 120) {
echo $s . $r['lotno'] . '*' . (120-$n) ."\n";
echo $r['lotno'] . '*' . ($n = $r['count'] - (120-$n)) ."\n";