简体   繁体   中英

Message: Trying to access array offset on value of type int

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);
     }

I resolved my own problem using in this way: if(isset($order['id'])) before I did in this way: if($order['id'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM