The problem is, I'm not getting the expected results of my array code.
I've tried doing the array_merge, but all it does was to merge all the arrays.
$medicine_order = $request['medicine_id'];
array:3 [▼
0 => "25"
1 => "32"
2 => "30"
]
$medicine_quantity = $request['medicine_quantity'];
array:3 [▼
0 => "3"
1 => "10"
2 => "6"
]
$count = 0;
foreach ($medicine_order as $id) {
$item = new Historyitem;
$item->medicine_id = $id;
foreach ($medicine_quantity as $id2) {
$item->historyitem_quantity = $id2;
}
$item->save();
$count++;
}
I wanted to store these values in my DB.
array:3 [▼
0 => "25"
1 => "3"
]
array:3 [▼
0 => "32"
1 => "10"
]
array:3 [▼
0 => "30"
1 => "6"
]
but instead I get these values:
array:3 [▼
0 => "25"
1 => "6"
]
array:3 [▼
0 => "32"
1 => "6"
]
array:3 [▼
0 => "30"
1 => "6"
]