ARTICLE AD BOX
I am looking for a solution to correctly insert CSV files into my database, taking special characters into account!
My CSV :
My form :
->add('csvFile', FileType::class,[ 'label' => 'insérer un fichier CSVN', 'label_attr' => [ 'class' => 'form-label mt-4' ], 'mapped' => false, 'required' => false, 'constraints' => [ new File( maxSize: '1024k', extensions: [ 'csv' => [ 'text/csv', 'application/csv', 'text/x-comma-separated-value', 'text/x-csv', 'text/plain', 'chartset=UTF-8' ] ], extensionsMessage: 'Insérer un fichier de type .csv valide', )],]) ->add('submit', SubmitType::class, [ 'attr' => ['class' => 'btn btn-primary mt-4 valider'], 'label' => 'Ajouter le csv' ])Here is the beginning of my code:
//controller $records = $csv->getRecords(); CSVParNum = []; foreach ($records as $record){ $CSVParNum[$record['Identifiant']] = $record; dd($CSVParNum); }My DD displays the CSV correctly, but if it has a field with an accent, for example, it displays a “b” before it:
//dd b"Date d'émission de la fiche" => "12/09/2025"If I continue my code by removing the DD and want to insert this field :
//controler $records = $csv->getRecords(); CSVParNum = []; foreach ($records as $record){ $CSVParNum[$record['Identifiant']] = $record; $date = $record["Date d'émission de la fiche"]; /.../ }I get an error message.
//alert Warning: Undefined array key "Date d'émission de la fiche"So what would be the solution to overcome this problem? Thank you :)

