I'm trying to collect data from a csv file and putting into a multidimensional array, to be later manipulated and put into a new csv.
Info on the CSVs (if needed)
The CSV contains orders from customers,and each line contains the quantity and SKU of one type of item in a given customer's order, as well as customer info such as address.
The reason why I'm using 3 dimensions for the array I collect the csv data in, is to separate lines into single customer orders.
Code
function order_data_collection() {
global $myfile;
$loopCount = 0;
$orderCount = 0;
$lineCount = 0;
$csvData = array();
$lastNum = "";
// actual data collection loop
while(! feof($myfile)) {
$loopCount++;
$line = array();
$line = fgetcsv($myfile);
if (!$line=fgetcsv($myfile,4096,',','"')) continue;
// cell data vars
$currNum = $line[0];
$currCountry = $line[6];
$currQty = $line[8];
$currSKU = $line[9];
$isFirstOrder = true;
if ($lastNum == $currNum) {
$isFirstOrder = false; $lineCount++;
} else {
$isFirstOrder = true; $orderCount++;
$lineCount = 0;
}
$parseCount = 0;
foreach ($line as $x) {
$csvData[$orderCount][$lineCount][$parseCount] = $x; $parseCount++;
}
$lastNum = $currNum;
}
}