I have a file of semi-colon separated values, say something like this:
1;data
2;data
3;data
...
Z;data
The number of lines Z can change per file. The idea is to parse the data and put it into a database. So I do the following:
$contents = file_get_contents($filename);
$line = explode(chr(13),$contents);
And now I go through line by line as follows and things are ok:
$n = 0;
while ($line[$n] != "") {
//lots of magic stuff that works
$n = $n + 1;
}
Now for reasons not necessary to explain, I need to parse line Z first and then go down to 1 instead. How should I simply go about doing this?