Flat-File - Which is Faster?
Posted: Sun Nov 24, 2002 10:42 am
Well....here goes. Everynight at midnight, my script will run to generate a new flat txt file that looks something like this:
It will have 5 new lines each day (always 5 lines total, just a different 5 lines each day). I will be wanting to produce these to HTML. My original intent was to do this (skip this if it seems too long)
I was going to have 5 different arrays, each with 5 elements. The script was going to run through the file and store all variables, then print them to HTML (also, if anyone can help with the above script I really don't know how to store each section of the file, then skip the || delimiter and move to the next variable).
But, I began to think....would it just be easier and run faster if the script never stored the file variables as actual variable, it just used one temporary variable, read from the file, the printed the HTML, then did it all over again?
Can anyone tell me which was would be faster and more effective, and possibly section a starting point on how to seperate the file from the delimiters? Thanks!
Code: Select all
Story Name||Story Author||Story Publisher||Story Date||Story PriorityCode: Select all
<?php
$nameArray = array("title","author","paper","date","priority");
$filePointer = fopen("stories.txt","r");
$fileArray = array();
$titleArray = array();
$authorArray = array();
$paperArray = array();
$dateArray = array();
$priorityArray = array();
$arrayCounter = 0;
$nameCounter = 0;
while ($nameCounter<=4)
{
$line = fgets($filePointer,4096);
while ($arrayCounter<=4)
{
$setArray = $nameArrayї$arrayCounter]."Array";
${$setArray}ї$nameCounter] = // ?? //
$arrayCounter++;
}
$arrayCounter = 0;
$nameCounter++;
}
fclose($filePointer);
?>But, I began to think....would it just be easier and run faster if the script never stored the file variables as actual variable, it just used one temporary variable, read from the file, the printed the HTML, then did it all over again?
Can anyone tell me which was would be faster and more effective, and possibly section a starting point on how to seperate the file from the delimiters? Thanks!