Есть массив mas_prod в нем есть элементы отличаются они только полем param. Как мне собрать уникальные где поле param собирется из всех похожих. вот пример массива. PHP: [2] => Array ( [price] => 1399.0000 [categoryId] => 63 [name] => Смокинг 2413 (Черный) [description] => [picture0] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9-2.jpeg [picture1] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9-3.jpeg [picture2] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9.jpeg [param] => Array ( [0] => Черный [1] => XXL [2] => S ) [quantity] => 17 ) [3] => Array ( [price] => 1399.0000 [categoryId] => 63 [name] => Смокинг 2413 (Черный) [description] => [picture0] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9-2.jpeg [picture1] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9-3.jpeg [picture2] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9.jpeg [param] => Array ( [0] => Черный [1] => XXL [2] => M ) [quantity] => 17 ) [4] => Array ( [price] => 1399.0000 [categoryId] => 63 [name] => Смокинг 2413 (Черный) [description] => [picture0] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9-2.jpeg [picture1] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9-3.jpeg [picture2] => https://tytmodno.com/image/data/1e/1e1ae661-8b0c-11e2-9502-8c89a5d9e6b9.jpeg [param] => Array ( [0] => Черный [1] => XXL [2] => L ) [quantity] => 17 )
в итоге должен остаться один массив из этих трух одинаковых в нем масив парам который содержит все параметры трех массивов.ну например в param должно быть PHP: [param] => Array ( [0] => Черный [1] => XXL [2] => S [3] => M [4] => L )
Спасибо. все сделал. Ну тут жесткий костыль и долго выполняется. но скорость щас тут не важна как бы. вот такой монстр. PHP: for($a = 0; $a <= 300;$a++){ if($mas['shop']['offers']['offer'][$i]['name'] === $mas['shop']['offers']['offer'][$a]['name'] and $a != $i){ $param .= ''.$mas['shop']['offers']['offer'][$i]['param'][0].'/'.$mas['shop']['offers']['offer'][$i]['param'][1].'/'.$mas['shop']['offers']['offer'][$a]['param'][1].'/'.$mas['shop']['offers']['offer'][$a]['param'][2].''.$mas['shop']['offers']['offer'][$a]['param'][3].''; $price = $mas['shop']['offers']['offer'][$i]['price']; $cat = $mas['shop']['offers']['offer'][$i]['categoryId']; $name = $mas['shop']['offers']['offer'][$i]['name']; $desc = $mas['shop']['offers']['offer'][$i]['description'][0]; if (trim(substr($mas['shop']['offers']['offer'][$i]['picture'][0], 0, 5)) === 'http') { $pic1 = $mas['shop']['offers']['offer'][$i]['picture'][0]; $pic2 = $mas['shop']['offers']['offer'][$i]['picture'][1]; $pic3 = $mas['shop']['offers']['offer'][$i]['picture'][2]; $pic4 = $mas['shop']['offers']['offer'][$i]['picture'][3]; }else{ $pic1 = ''.$mas['shop']['offers']['offer'][$i]['picture'].'a'; } $quan = $mas['shop']['offers']['offer'][$i]['quantity']; unset($mas['shop']['offers']['offer'][$a]); }else{ if($a == 300){ if($param == ''){ $price = $mas['shop']['offers']['offer'][$i]['price']; $cat = $mas['shop']['offers']['offer'][$i]['categoryId']; $name = $mas['shop']['offers']['offer'][$i]['name']; $desc = $mas['shop']['offers']['offer'][$i]['description'][0]; if (trim(substr($mas['shop']['offers']['offer'][$i]['picture'][0], 0, 5)) === 'http') { $pic1 = $mas['shop']['offers']['offer'][$i]['picture'][0]; $pic2 = $mas['shop']['offers']['offer'][$i]['picture'][1]; $pic3 = $mas['shop']['offers']['offer'][$i]['picture'][2]; $pic4 = $mas['shop']['offers']['offer'][$i]['picture'][3]; }else{ $pic1 = $mas['shop']['offers']['offer'][$i]['picture']; } $quan = $mas['shop']['offers']['offer'][$i]['quantity']; $param .= ''.$mas['shop']['offers']['offer'][$i]['param'][0].'/'.$mas['shop']['offers']['offer'][$i]['param'][1].''; } $i++; } } } if($name != ''){ $mas_prod2[] = array( 'price' => $price, 'categoryId' => $cat, 'name' => $name, 'description' => $desc, 'picture0' => $pic1, 'picture1' => $pic2, 'picture2' => $pic3, 'picture3' => $pic4, 'param' => $param, 'quantity' => $quan, ); } $param = ''; }