I created this script, but its not working. Through troubleshooting it seems that the $i variable isn't being read in:
$dir_path = "../html/content/articles/" . $date . "/commentary/" . $columnist_dir_array[$i] . "/";
If I replace the $i with a 0 or 1 it seems to work. I tried printing $i in the loop to ensure the variable is making it into the loop and $i prints fine.
As is, the script times out without any errors. Would there be a reason the $i wouldn't work in $dir_path = "../html/content/articles/" . $date . "/commentary/" . $columnist_dir_array[$i] . "/";
Please let me know if you see a syntax error or a problem that I may have over looked. Thanks!
// Array of columnists
$columnist_dir_array[0] = "columnist1";
$columnist_dir_array[1] = "columnist2";
$columnist_dir_array[2] = "columnist3";
$columnist_dir_array[3] = "columnist4";
$columnist_dir_array[4] = "columnist5";
$columnist_dir_array[5] = "columnist6";
$columnist_dir_array[6] = "columnist7";
$columnist_dir_array[7] = "columnist8";
$columnist_dir_array[8] = "columnist9";
// Add columnists by adding to bottom of array (above), name represents directory name
// Number of columnists - starting at 1
$count_col = count($columnist_dir_array);
for ($i = 0; $i < $count_col; $i++) {
// Look for latest date with .txt files
$adjust = -1;
do
{
$adjust++;
$date = strftime ("%Y/%m/%d", strtotime("-$adjust day"));
// Directory Variable
$dir_path = "../html/content/articles/" . $date . "/commentary/" . $columnist_dir_array[$i] . "/";
// Create array of .txt file names
$file_names = glob($dir_path . '*.txt');
// Count array
$count_txt = count($file_names);
}
while ($count_txt == 0);
$count = 1;
if ( is_array ( $file_names ) ) {
// Diplay [story_component] tokens for each file
foreach ($file_names as $file) {
echo "<span class='headline'>[story_component:commentary/" . $columnist_dir_array[$i] . ":" . $count . ":headline-link]</span><br />
<span class='italictext12'>[story_component:commentary/" . $columnist_dir_array[$i] . ":" . $count . ":byline]</span><br />
<p class='article_spacing'><span class='text12'>[story_component:commentary/" . $columnist_dir_array[$i] . ":" . $count . ":paragraphs:1:1]</span>
<span class='italictext10'> - [date]</span></p>";
$count++;
}
}
}