我讀一個文件和下面一旦讀取是csv_array數據:更新表給出在laravel未定義,偏移
Array (
[0] => "1"
[1] => "1468409102803"
[2] => "dd 22"
[3] => "test1"
[4] => "test2"
[5] => "test3"
[6] => "testcity"
[7] => "11111"
[8] => ""
[9] => ""
[10] => "1234567"
[11] => "GI230"
[12] => "Eveready Reachargeable Torch DL91"
[13] => "1"
)
以上述陣列更新訂單表如下:
DB::table('orders')->where('order_number',$csv_array[1])->update(array('ship_address1'=>$csv_array['3'],'ship_address2'=>$csv_array['4'],'ship_address3'=>$csv_array['5'],'ship_city'=>$csv_array['6'],'ship_zip'=>$csv_array['7']));
錯誤來是:
未定義偏移1
檢查'的print_r($ csv_array)'它是一個數組或字符串以數組格式。 – C2486
請刪除像$ csv_array [3]陣列的引號,並檢查 –
嘗試'dd($ csv_array [1]);'看看你到底在做什麼 –