Получить все комбинации из нескольких массивов по ключу

Я работаю над проблемой.
Я хочу генерировать все комбинации из нескольких массивов.
Мои несколько массивов — это продукты, цвета, размеры и модели.

$products = array("prd_type"=> "prd","code"=>58,"stext"=>"Magnum Frame");
$colors = array();
$colors[] = array("prd_type"=> "color","code"=>60,"stext"=>"Pink");
$colors[] = array("prd_type"=> "color","code"=>61,"stext"=>"Red");
$colors[] = array("prd_type"=> "color","code"=>62,"stext"=>"Black");
$sizes = array();
$sizes[] = array("prd_type"=> "size","code"=>70,"stext"=>"M");
$sizes[] = array("prd_type"=> "size","code"=>71,"stext"=>"S");
$sizes[] = array("prd_type"=> "size","code"=>72,"stext"=>"XL");
$models = array();
$models[] = array("prd_type"=> "model","code"=>80,"stext"=>"Xmall");
$models[] = array("prd_type"=> "model","code"=>81,"stext"=>"Xtra");
$models[] = array("prd_type"=> "model","code"=>82,"stext"=>"Xcode");

В результате создается массив комбинаций, как показано ниже.

$results = array();
$results[] = array("localCode"=>"58","ltext"=>"Magnum Frame");
$results[] = array("localCode"=>"58,60","ltext"=>"Magnum Frame - Pink");
$results[] = array("localCode"=>"58,60,70","ltext"=>"Magnum Frame - Pink - M");
$results[] = array("localCode"=>"58,60,70,80","ltext"=>"Magnum Frame - Pink - M - Xmall");
$results[] = array("localCode"=>"58,61","ltext"=>"Magnum Frame - Red");
$results[] = array("localCode"=>"58,61,70","ltext"=>"Magnum Frame - Red - M");
#...
#etc
$results[] = array("localCode"=>"82","ltext"=>"Xcode")

Ключ localCode, где сгенерированный массив, были сгенерированы из код ключ в атрибутах.

Как я могу генерировать как вышеупомянутый результат?

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector