Необходимо из данных в переменной $data получить все возможные варианты, как указано в переменной $expected
$data = [
[
'rates' => [1, 2],
'origin' => 1,
],
[
'rates' => [3, 4],
'origin' => 2,
],
[
'rates' => [5],
'origin' => 3,
],
];
// нужно получить все возможные комбинации, как показано ниже
$expected = [
[
[
'rate' => 1,
'origin' => 1,
],
[
'rate' => 3,
'origin' => 2,
],
[
'rate' => 5,
'origin' => 3,
],
],
[
[
'rate' => 1,
'origin' => 1,
],
[
'rate' => 4,
'origin' => 2,
],
[
'rate' => 5,
'origin' => 3,
],
],
[
[
'rate' => 2,
'origin' => 1,
],
[
'rate' => 3,
'origin' => 2,
],
[
'rate' => 5,
'origin' => 3,
],
],
[
[
'rate' => 2,
'origin' => 1,
],
[
'rate' => 4,
'origin' => 2,
],
[
'rate' => 5,
'origin' => 3,
],
],
];