我有两个数组。我只想将两个数组合并为一个数组。
public function get_products()
{
$products = DB::table('products')->get();
$arr = array();
foreach ($products as $item)
{
$productImagedata['image'] = DB::table('product_image')-
>where('product_id', $item->id)->get();
array_combine( $arr, $productImagedata );
}
$pagedata = collect([ "products" => $products ]);
$data = collect(["status" =>
["code" => "100", "message" => "Success", "data" => $pagedata]]);
return response()->json($data, 200);
}
在上面的代码中。第二个数组应该包含在第一个数组的值中
我只是想喜欢这个
"products": [
{
"product_id": 2,
"product_name": "xyz",
"image": [
{
"id": 2,
"image_name": "i.jpg",
}
]
},
守着一只汪
摇曳的蔷薇
MMMHUHU