Вам нужна рекурсивная функция
function slug(string $start, $arrays): array
{
$result = [];
$current = array_shift($arrays);
$isLast = count($arrays) === 0;
foreach ($current as $value) {
$path = !empty($start) ? $start . '/' . $value : $value;
if ($isLast) {
$result[] = $path;
} else {
$result = array_merge($result, slug($path, $arrays));
}
}
return $result;
}
$array1 = [
'brand-1',
'brand-2',
'brand-3',
];
$array2 = [
'style-1',
'style-2',
'style-3',
];
$array3 = [
'color-1',
'color-2',
];
var_dump(slug('', [$array1, $array2, $array3]));
array (size=18)
0 => string 'brand-1/style-1/color-1' (length=23)
1 => string 'brand-1/style-1/color-2' (length=23)
2 => string 'brand-1/style-2/color-1' (length=23)
3 => string 'brand-1/style-2/color-2' (length=23)
4 => string 'brand-1/style-3/color-1' (length=23)
5 => string 'brand-1/style-3/color-2' (length=23)
6 => string 'brand-2/style-1/color-1' (length=23)
7 => string 'brand-2/style-1/color-2' (length=23)
8 => string 'brand-2/style-2/color-1' (length=23)
9 => string 'brand-2/style-2/color-2' (length=23)
10 => string 'brand-2/style-3/color-1' (length=23)
11 => string 'brand-2/style-3/color-2' (length=23)
12 => string 'brand-3/style-1/color-1' (length=23)
13 => string 'brand-3/style-1/color-2' (length=23)
14 => string 'brand-3/style-2/color-1' (length=23)
15 => string 'brand-3/style-2/color-2' (length=23)
16 => string 'brand-3/style-3/color-1' (length=23)
17 => string 'brand-3/style-3/color-2' (length=23)