I´m trying to create this structure to send data to API
$metaDataList = [
[
"key" => "item_description0",
"value" => "DCALUXE",
]
];
i need this structure.
I´m trying to do this:
$items_selected = [];
for($i=0; $i<count($precontractData->items);$i++){
$items_selected["item_description$i"] = $precontractData->items[$i]->name;
$items_selected["item_quantity$i"] = intval($precontractData->items[$i]->cuantity);
}
array_push($metaDataList, $items_selected);
but my result it´s not equal to my needed structure. I try with merge array, i try with array_map, but i don´t know how i can to do one array with this structure. in key "key" should be "item_description$i"
and in value should be $precontractData->items[$i]->name
Thanks for readme and sorry for my bad english
array_push()
in a loop: 3v4l.org/dooRo