I want to extract data from an ASC file. But when I try to extract data from it it tells me that it has an undefined offset?
This is the code that I use to extract the data (the error occurs at $data2, $data is fine):
$File = $_FILES['file']['tmp_name'];
$File2 = $_FILES['file2']['tmp_name'];
$handle = fopen($File, "r");
$handle2 = fopen($File2, "r");
$arrResult = array();
$arrResult2 = array();
fgetcsv($handle);
fgetcsv($handle);
fgetcsv($handle);
fgetcsv($handle);
fgetcsv($handle);
fgetcsv($handle);
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE && ($data2 = fgetcsv($handle2, 1000, ";")) !== FALSE) {
//---------------------
$artikelnmr = $data[0];
$barcode = $data[1];
$omschrijving_nl = $data[2];
$omschrijving_exp = $data[3];
$bruto_prs = $data[4];
$staffel_prs = $data[5];
$aktie_prs = $data[6];
$bruto_antl = $data[8];
$staffel_antl = $data[9];
$aktie_aantal = $data[10];
$voorraad = $data[15];
$leverdatum = $data[16];
$besteld = $data[17];
$pallet_antl = $data[19];
$artikel_groep = $data[22];
$extra_info = $data[27];
//-----------------------
$type = $data2[0][0];
$artikel = $data2[0][1];
$prijs1 = $data2[5];
$prijs2 = $data2[6];
$prijs3 = $data2[7];
$prijs4 = $data2[8];
$prijs5 = $data2[9];
//----------------------
And this is the error that gets returned:
( ! ) Notice: Undefined offset: 5 in C:\wamp64\www\jodeco\import.php on line 53 Call Stack
Time Memory Function Location
1 0.0011 414880 {main}( ) ...\import.php:0
2 0.0032 430384 importdb( ) ...\import.php:222
And this also happens for all the other data points (5 to 9)
Here are a few rows of the ASC file:
0 1 2 3 4 5 6 7 8 9 10 11
---------------------------------------------------------------------------------------------------------------------------------
5 ;790148 ; ; ; ; 4.35; 0.00; ; ; 0.00; ; ;
1 ;790148 ; ; ; ; 4.35; 0.00; ; ; 0.00; ; ;