0

Есть первым массив $arOrderSmart

Array
(
    [0] => Array
        (
            [ID] => 7
            [XML_ID] => 
            [TITLE] => asdasd
            [CREATED_BY] => 1
            [UPDATED_BY] => 1
        )

    [1] => Array
        (
            [ID] => 8
            [XML_ID] => 
            [TITLE] => gggggggggggg
            [CREATED_BY] => 1
            [UPDATED_BY] => 1
        )

)

и второй массив $arElements

    Array
(
    [0] => Array
        (
            [ID] => 40486
            [PROPERTY_ORDER_VALUE] => 7
            [PROPERTY_ORDER_VALUE_ID] => 40486:286
            [PROPERTY_HEADER_ID_VALUE] => 234124
            [PROPERTY_HEADER_ID_VALUE_ID] => 40486:287
            [PROPERTY_ORDER_NUMBER_VALUE] => 1234
            [PROPERTY_ORDER_NUMBER_VALUE_ID] => 40486:288
        )

)


    Array
    (
        [0] => Array
            (
                [ID] => 40483
                [PROPERTY_ORDER_VALUE] => 8
                [PROPERTY_ORDER_VALUE_ID] => 40483:286
                [PROPERTY_HEADER_ID_VALUE] => 38
                [PROPERTY_HEADER_ID_VALUE_ID] => 40483:287
                [PROPERTY_ORDER_NUMBER_VALUE] => 123123
                [PROPERTY_ORDER_NUMBER_VALUE_ID] => 40483:288
            )
    
        [1] => Array
            (
                [ID] => 40485
                [PROPERTY_ORDER_VALUE] => 8
                [PROPERTY_ORDER_VALUE_ID] => 40485:286
                [PROPERTY_HEADER_ID_VALUE] => 111
                [PROPERTY_HEADER_ID_VALUE_ID] => 40485:287
                [PROPERTY_ORDER_NUMBER_VALUE] => 444
                [PROPERTY_ORDER_NUMBER_VALUE_ID] => 40485:288
            )
    
    )

хочу в итоге получить такой

Array
(
    [0] => Array
        (
            [data] => Array
                (
                    [0] => Array
                        (
                            [ID] => 40486
                            [PROPERTY_ORDER_VALUE] => 7
                            [PROPERTY_ORDER_VALUE_ID] => 40486:286
                            [PROPERTY_HEADER_ID_VALUE] => 234124
                            [PROPERTY_HEADER_ID_VALUE_ID] => 40486:287
                            [PROPERTY_ORDER_NUMBER_VALUE] => 1234
                            [PROPERTY_ORDER_NUMBER_VALUE_ID] => 40486:288
                        )

                )

        )

    [1] => Array
        (
            [data] => Array
                (
              
                    [0] => Array
                        (
                            [ID] => 40483
                            [PROPERTY_ORDER_VALUE] => 8
                            [PROPERTY_ORDER_VALUE_ID] => 40483:286
                            [PROPERTY_HEADER_ID_VALUE] => 38
                            [PROPERTY_HEADER_ID_VALUE_ID] => 40483:287
                            [PROPERTY_ORDER_NUMBER_VALUE] => 123123
                            [PROPERTY_ORDER_NUMBER_VALUE_ID] => 40483:288
                        )

                    [2] => Array
                        (
                            [ID] => 40485
                            [PROPERTY_ORDER_VALUE] => 8
                            [PROPERTY_ORDER_VALUE_ID] => 40485:286
                            [PROPERTY_HEADER_ID_VALUE] => 111
                            [PROPERTY_HEADER_ID_VALUE_ID] => 40485:287
                            [PROPERTY_ORDER_NUMBER_VALUE] => 444
                            [PROPERTY_ORDER_NUMBER_VALUE_ID] => 40485:288
                        )

                )
        )
)

как это делаю я

$ar = [];
    foreach ($arOrderSmart as $aRes) {
        $arElements = $this->getLineElements($aRes['ID']);

        foreach ($arElements as $itemElement) {

            if ($itemElement['PROPERTY_ORDER_VALUE'] == $aRes['ID']) {
                $columns = [
                    'ORDER' => $itemElement['ID']
                ];
                $ar[] = $itemElement;
            }
        }
        $aRows[] = ["data" => $ar, "columns" => $columns, "editable" => true];
    }

но выходит не то что нужно, прошу помочь разобраться

1 ответ 1

0

протупил

$ar = [];
foreach ($arOrderSmart as $aRes) {
        $arElements = $this->getLineElements($aRes['ID']);

        foreach ($arElements as $k => $itemElement) {

           $ar[$k] = $itemElement
        }
        $aRows[] = ["data" => $ar, "columns" => $columns, "editable" => true];
    }

Ваш ответ

Нажимая «Отправить ответ», вы соглашаетесь с условиями пользования и подтверждаете, что прочитали политику конфиденциальности.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.