php添加元素到数组无法正常工作

I'm inserting elements dinamically in array, elements are inserted OK, but only the last one

I think that push_array will solve the problem, and I try

array_push($rowsItemAddit, $rowsItemAddit["item"]["acId"], $precio_row_addit->acId);

But I get error

Notice: Undefined index: item

My code working for the last element is

foreach($precios_row_addit as $precio_row_addit){
    $rowsItemAddit["item"]["acId"] = $precio_row_addit->acId;
    $rowsItemAddit["item"]["acValues"]  = array ( 'acValue' => $precio_row_addit->acValue );                    
    }

Any ideas to get the complete array?

The final structure should be:

[additionalColumnValues] => Array
    (
        [item] => Array
            (
                [acId] => 0
                [acValues] => Array
                    (
                        [acValue] => 10
                    )

            )
        [item] => Array
            (
                [acId] => 1
                [acValues] => Array
                    (
                        [acValue] => 10
                    )

            )               
        [item] => Array
            (
                [acId] => etc.
                [acValues] => Array
                    (
                        [acValue] => 10
                    )

            )
    )

        )

)

TIA

You need to code it like this

foreach ($precios_row_addit as $precio_row_addit) {
    $rowsItemAddit[] = array('item' => array(
            'acId' => $precio_row_addit->acId,
            'acValues' => array('acValue' => $precio_row_addit->acValue)
        ));
}

You always try to overwrite the same array elements. It can't have multiple keys named "item"

Try something like this, where the item index is an numeric index rather than "item":

foreach($precios_row_addit as $precio_row_addit){
    $rowsItemAddit[]["acId"] = $precio_row_addit->acId;
    $rowsItemAddit[]["acValues"] = array ( 'acValue' => $precio_row_addit->acValue );                    
}