0

I'm trying to upload an excel file... but my string contains this special character "°" how could avoid it to upload into my database?

use Maatwebsite\Excel\Concerns\WithHeadingRow;
class IncidenciasImport implements OnEachRow, WithHeadingRow
{
      public function onRow(Row $row)
      {  
      $row = $row->toArray();
      $incidencias = Incidencias::firstOrCreate([
            'nro_ticket_prov' => $row['n_ticket_proveedor'],
      ]);
}
}
Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
Oscar
  • 139
  • 1
  • 13

1 Answers1

1

I am not sure if it is the best solution but you could simply use the strg_replace function. The first argument is what you are searching for in this case "°", with the second arguments you say "replace it with this string". And the third argument is your object in which you want to replace it.

So in your case it may look something like this:

str_replace('"°"', '', $row['n_ticket_proveedor']);

This would replace it with an empty string.

But in your case I would check what "°" stand for in excel and replace it properly.

utdev
  • 3,942
  • 8
  • 40
  • 70
  • I got this Undefined index: n_ticket_proveedor – Oscar Jan 21 '20 at 20:22
  • @Oscar which variable contains your string replace that with the third parameter and you should be fine or get at least some result – utdev Jan 21 '20 at 21:04