Reputation: 61
How to resolve this issues: Trying to access array offset on value of type int?
PHP8
public function processPayment(Request $request)
{
$orders = $request->get('order');
$ordersArray = [];
// getting orders details
foreach($orders as $order)
{
if($order['id'])
{
$ordersArray[$order['id']]['order_id'] = $order['id'];
$ordersArray[$order['id']]['quantity'] = $order['quantity'];
}
ddd($ordersArray);
}
Upvotes: 1
Views: 11053
Reputation: 61
I resolved my own problem using in this way: if(isset($order['id']))
before I did in this way:if($order['id'])
Upvotes: 3