I am using this function to create array:
$products = $request->input('product');
$productinput = array();
foreach (array_keys($products) as $fieldKey) {
foreach ($products[$fieldKey] as $key=>$value) {
$productinput[$key][$fieldKey] = $value;
}
}
return $productinput;
and this is what it is returning via json_encode:
[
{"product_id":"63","product_batch":"BAtch1","product_quantity":"50","product_price":"200","discount":"0","net_price":"20000"},
{"product_id":"67","product_batch":"Batch2","product_quantity":"50","product_price":"200","discount":"0","net_price":"20000"}
]
Now I need to rename product_quantity to quantity and product_price to price. Is there anyone to help me out?