我正在使用此函数创建数组:
$products = $request->input('product');
$productinput = array();
foreach (array_keys($products) as $fieldKey) {
foreach ($products[$fieldKey] as $key=>$value) {
$productinput[$key][$fieldKey] = $value;
}
}
return $productinput;
这就是它通过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"}
]
现在我需要将product_quantity
重命名为quantity
,将product_price
重命名为price
。有没有人帮助我?