Hello,
I have a few text files that I would like to load into an array. I know how to load 1 dimensional data into an array, but I do not know how to add multidimensional data into an array. I suppose I need to parse the lines of data into elements somehow and load each line as an array to the existing array, but I do not know how to do that.
My text file stores 5 elements per line separated by commas (',') and looks like this:
Q,100,Support,20090101,50
Q,119,Support,20010203,49
I would like the array structured in 2 dimensions, so I could reference the items by row and column.
I have a few text files that I would like to load into an array. I know how to load 1 dimensional data into an array, but I do not know how to add multidimensional data into an array. I suppose I need to parse the lines of data into elements somehow and load each line as an array to the existing array, but I do not know how to do that.
My text file stores 5 elements per line separated by commas (',') and looks like this:
Q,100,Support,20090101,50
Q,119,Support,20010203,49
I would like the array structured in 2 dimensions, so I could reference the items by row and column.
PHP Code:
var aArray = new Array[];
function preMain() {
loadData();
}
function loadData() {
var f = new File(MyFile.txt);
var i = 0;
if( f.exists() ) {
f.open("rt");
while( !f.eof()) {
aArray[i] = f.readln();
i++;
}
}
//debugPrintln(aArray);
return;
}
Comment