add shipping rules
This commit is contained in:
@@ -14,6 +14,7 @@ class Arrays
|
||||
}
|
||||
}
|
||||
unset($array[$oldkey]);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -35,31 +36,32 @@ class Arrays
|
||||
public static function alternate_chunk($array, $parts)
|
||||
{
|
||||
$t = 0;
|
||||
$result = array();
|
||||
$result = [];
|
||||
$max = ceil(count($array) / $parts);
|
||||
foreach (array_chunk($array, $max) as $v) {
|
||||
if ($t < $parts) {
|
||||
$result[] = $v;
|
||||
} else {
|
||||
foreach ($v as $d) {
|
||||
$result[] = array($d);
|
||||
$result[] = [$d];
|
||||
}
|
||||
}
|
||||
$t += count($v);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function fill_chunk($array, $parts)
|
||||
{
|
||||
$t = 0;
|
||||
$result = array_fill(0, $parts - 1, array());
|
||||
$result = array_fill(0, $parts - 1, []);
|
||||
$max = ceil(count($array) / $parts);
|
||||
foreach ($array as $v) {
|
||||
count($result[$t]) >= $max and $t ++;
|
||||
count($result[$t]) >= $max and $t++;
|
||||
$result[$t][] = $v;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user