I have a list of products in a CSV file that I'm trying to pass to a database.
This is my code to open the file.
$tmp_archivo = "file/catalogo.csv";
$archivo = fopen($tmp_archivo, "r");
$row = 0;
if($archivo){
while ($datos = fgetcsv($archivo, ",")){
echo utf8_encode($datos[0])."-".utf8_encode($datos[1])."-".utf8_encode($datos[2])."-".utf8_encode($datos[3])."-".utf8_encode($datos[4])."-".utf8_encode($datos[5])."-".utf8_encode($datos[6])."-".utf8_encode($datos[7])."-"."<br>";
}
}
But I get the following lines.
100010008-Alambre galvanizado Nº 18-KG--10001-HAWA-Z205-;;;-
100010009-Alambre negro recocido Nº 16-KG-COD.ANT.-10001-HAWA-Z205-GRUPO ART. EXT.;;;-
Notice: Undefined offset: 1 in /var/www/html/Sis_Pecosa/index.php on line 11
Notice: Undefined offset: 2 in /var/www/html/Sis_Pecosa/index.php on line 11
Notice: Undefined offset: 3 in /var/www/html/Sis_Pecosa/index.php on line 11
Notice: Undefined offset: 4 in /var/www/html/Sis_Pecosa/index.php on line 11
Notice: Undefined offset: 5 in /var/www/html/Sis_Pecosa/index.php on line 11
Notice: Undefined offset: 6 in /var/www/html/Sis_Pecosa/index.php on line 11
Notice: Undefined offset: 7 in /var/www/html/Sis_Pecosa/index.php on line 11
100010010,"Alcayata de acero De 2 1/2""",UN,,10001,HAWA,Z205,;;;--------
lines of my CSV file:
100010008,Alambre galvanizado Nº 18,KG,,10001,HAWA,Z205,
100010009,Alambre negro recocido Nº 16,KG,COD.ANT.,10001,HAWA,Z205,GRUPO ART. EXT.
100010010,"Alcayata de acero De 2 1/2""",UN,,10001,HAWA,Z205,
Some lines if you print them normal, others do not, any help?
Thank you.