I have a big .txt file (73 thousand lines) and i need to store the data from that file in an array.
Here is an example of how the file looks, it just repeats in this fashion, every line looks like this.
2016-05-27 11:04:16: QParRFSum=1574.00 QParRFSumMean=6.05 QParSuspSum=83.00
2016-05-27 11:14:07: QParRFSum=1537.00 QParRFSumMean=5.91 QParSuspSum=96.00
2016-05-27 11:14:07: QParRFSum=1537.00 QParRFSumMean=5.91 QParSuspSum=96.00
2016-05-27 11:24:07: QParRFSum=1405.00 QParRFSumMean=5.40 QParSuspSum=0.00
2016-05-27 11:24:07: QParRFSum=1405.00 QParRFSumMean=5.40 QParSuspSum=0.00
2016-05-27 11:34:06: QParRFSum=1533.00 QParRFSumMean=5.90 QParSuspSum=89.00
2016-05-27 11:34:06: QParRFSum=1533.00 QParRFSumMean=5.90 QParSuspSum=89.00
And I would like to put this into an array with keys like this:
Array (
[0] =>
(
[date] => 2016-05-27
[time] => 11:04:16
[QParRFSum] => 1574.00
[QParRFSumMean] => 6.05
[QParSuspSum] => 83.00
)
[1] =>
(
[date] => 2016-05-27
[time] => 11:14:07
[QParRFSum] => 1537.00
[QParRFSumMean] => 5.91
[QParSuspSum] => 96.00
)
[2] =>
(
[date] => 2016-05-27
[time] => 11:14:07
[QParRFSum] => 1537.00
[QParRFSumMean] => 5.91
[QParSuspSum] => 96.00
)
)
And so on...
How would i do this in the best way, having performance in mind?
My thought was to go through it line by line with the file() function and a foreach loop. And then somehow process it into the array structure I want. Something like this:
$txt=file('path/to/file');
foreach($txt as $line)
{
$RFAValues[] = $line;
}
Is this the way to go, or is there a better way which will give me better performance?