- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest1.php
More file actions
Latest commit
20 lines (20 loc) · 462 Bytes
/
Copy pathtest1.php
File metadata and controls
20 lines (20 loc) · 462 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
// https://github.com/BaseMax/PartitionArrayPHP
functionpartition($transport,$sizes) {
$results = [];
foreach ($sizesas$size) {
$current = [];
foreach(range(1,$size) as$no) {
$mode = current($transport);
$current[]=$mode;
next($transport);
}
$results[] = array_filter($current);
}
return$results;
}
///////////////////////////////////////
$input=[1,2,3,4,5,6,7];
$size=[3,2,2];
$output=partition($input, $size);
print_r($output);