Здравствуйте. Есть массив: Код (Text): array(3) 0: array(7) attribute_id: "14" attribute_group_id: "7" attribute_name: "Пятна" attribute_group_name: "Проблема" display_mode: "on" type: "multi" values: array(1) 1: array(7) attribute_id: "16" attribute_group_id: "8" attribute_name: "Витамин C" attribute_group_name: "Активные ингредиенты" display_mode: "on" type: "single" values: array(2) 2: array(7) attribute_id: "17" attribute_group_id: "8" attribute_name: "Витамин Е" attribute_group_name: "Активные ингредиенты" display_mode: "on" type: "single" values: array(1) Надо преобразовать его в такой: Код (Text): array(2) 0: array(3) attribute_group_id: "7" attribute_group_name: "Проблема" attributes: array(1) 0: array(5) attribute_id: "14" attribute_name: "Пятна" display_mode: "on" type: "multi" values: array(1) 1: array(3) attribute_group_id: "8" attribute_group_name: "Активные ингредиенты" attributes: array(2) 0: array(5) attribute_id: "17" attribute_name: "Витамин Е" display_mode: "on" type: "single" values: array(1) 1: array(5) attribute_id: "16" attribute_name: "Витамин C" display_mode: "on" type: "single" values: array(2) Надо обойти первый массив и если attribute_group_id совпадает, то поместить пары ключ-значение, не относящиеся к attribute_group в отдельный массив и поместить его в массив attributes в группе.