I'm having a bit of problems trying to remember how to go about doing this, but here's my problem:
I need to make a quick process to read files from a directory, open each one up and run through another script that outputs the content of each text file into a particular, readable format. I know that this can be done via making a form. As an ultra simple and quick solution, I'm trying to open a defined list of paths of text files ("essaysrclist.txt"), place each line into an array and run each element through a loop (running the data processing code) until the array list's index is maxed. It's simple enough, but I'm having problems with assigning a path to a variable via a variable. Everything only works when I initialize the path variable with the path as a string.
ex. @$array = "./filepath/file.txt"; // works
vs.
$arraytemp = strval($arraylist[0]); // arraylist[0] is
"./filepath/file.txt"
@ $arraysrc = file($arraytemp); // doesn't work
Can someone please help lead me in the right direction?
Thanks ahead of time.
larger example of code below:
*****
//path of essay list stored in variable
$anttest = "essaysrclist.txt";
$anttest = strval($anttest);
//open file list
@ $essaylist = file($anttest);
if (!$essaylist)
{
echo "<p><strong>The Essay file list could not be
opened at this time. Please contact the administrator.
FOR ESSAYLIST</strong></p></body></html>";
exit;
}
//count number of files
$essaycount = count($essaylist);
print "**************************<br />";
print "Number of Essays in List: $essaycount <br />";
print "**************************<br /><br />";
//list essays
print "**************************<br />";
print "Essays to be Checked:<br />";
for ($i=0; $i<$essaycount; $i++)
{
print "$essaylist[$i] <br />";
}
print "**************************<br /><br />";
//open the essay file from list
$essaytemp = strval($essaylist[0]);
$test = strval($test);
//$test = "./testfiles/essaysrc.txt";
@ $essaysrc = file($essaytemp);
//@ $essaysrc = file("./testfiles/essaysrc.txt");
print "+++++++++test variable: $test +++++++++++++ <br
/>";
print "+++++++++essaysrc variable: $essaysrc +++++++++++++
<br />";
print "+++++++++essaytemp variable: $essaytemp
+++++++++++++ <br />";
print "+++++++++essaylist @ index 0 variable:
$essaylist[0] +++++++++++++ <br />";
print "<br><br>";
print "===============<br>";
if (!$essaysrc)
{
echo "<p><strong>The Essay file could not be opened at
this time. Please contact the administrator. FOR
ESSAYSRC</strong></p></body></html>";
exit;
}