Tour Array in Laravel

0

I'm going through the following array:

$register = array_values($array);
    foreach($register as $key => $value) {
        $var = explode('"', $value[0]);

        $transfer = new Transfers;
        $transfer->date = Carbon::CreateFromFormat("d/m/Y", $var[1])->format('Y-m-d');
        $transfer->bank_id = 1;
        $transfer->reference = $var[3];
        $transfer->description = $var[5];
        $transfer->amount = $var[7];
        $transfer->status = "Sin validar";
        $transfer->save();            
    }

At the moment of making a dd($var[i]) , it prints without any problem, but when continuing to register, it returns the following: Undefined offset: 1

    
asked by Erain Moya 21.08.2018 в 13:22
source

1 answer

0

The error says it, there is no index in the array that is created from what returns explode , check that when you make explode you always return the index (s) you want to access.

    
answered by 22.08.2018 в 18:40