UM
$array = [1,2,3,4,5,6,7,8,9,0];
$resArray = [];
foreach ($array as $key => $value) {
$temp = $array;
array_splice($temp, $key, 1);
$resArray += [$value => $temp];
}
print_r($resArray);
Но будет работать только при плоском массиве
Size: a a a
️️
$array = [1,2,3,4,5,6,7,8,9,0];
$resArray = [];
foreach ($array as $key => $value) {
$temp = $array;
array_splice($temp, $key, 1);
$resArray += [$value => $temp];
}
print_r($resArray);
️️
️️
/
/
/
/
ДК
S
M
/
ДК
/
/
️️
$array = [1,2,3,4,5,6,7];
$new = [];
foreach( $array as $key => $value ){
$temp = $array;
unset($temp[$key]);
$new[] = $temp;
}
var_dump($new);
️️
ДК
/
ДК