简体   繁体   中英

ErrorException Uninitialized string offset: 1

I have a purchase orders form, and on the form there are multiple identical fields, like in this picture below. I can store this form with 1 or 2 discount with 1 or 2 products, but when i store this form with "3 discount with 3 different products" i got this notice error Uninitialized string offset: 1 表格

Notice:

ErrorException
Uninitialized string offset: 1

错误消息

Structure table: 在此处输入图片说明

I had the same problem, and I changed my loop like below, I really did not understand where was the problem, but this was a suggestion to use like this from someone. so my problem solved.

 foreach ($request->input('category_id') as $item => $value) {
     $orderDetail = new orderDetail();
     $orderDetail ->id= $request->id;
     $orderDetail ->supplier_id= $request->supplier_id[$item];
    .
    .
    .
     $orderDetail ->status = 0;

     $orderDetail ->save();
}

I hope this work for you.

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