Suntra:
Thanks for your help, however I still cannot get the javascript to read the variable. Below is how I have coded your suggestion. below that is a copy of the results.....I guess I am a little dense but I do not get the variable.
Pig: I am sorry but I did not follow the heredoc at all.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html><head>
</head>
<BODY>
start of html
<script language="javascript" type="text/javascript">
<?php
$filename = "linksfile.txt";
$page[0] = "index.html";
$page[1] = "about.htm";
$page[2] = "news.htm";
$page[3] = "meminfo.html";
$page[4] = "contact.html";
$page[5] = "golf.htm";
$page[6] = "tennis.htm";
$page[7] = "fanda.htm";
$page[8] = "dining.htm";
$page[9] = "social.htm";
$page[10] = "weddings.htm";
$page[11] = "banquets.htm";
$page[12] = "contact.htm";
$page[13] = "PDFgallery.htm";
$page[14] = "faq-home.htm";
$green = "grdot.png\n";
$yellow = "yedot.png\n";
$none = "nodot.png\n";
$lfh = fopen($filename, 'w') or die("can't open file");
flock($lfh, LOCK_EX);
$i = 0;
while ($i < count($page))
{
$pagename =trim($page[$i]);
$linkdate = date ("Y-m-d ", filemtime($pagename));
$diff = (strtotime(date("Y-m-d")) - strtotime($linkdate)) / (60 60 24);
echo "file ".$pagename." Datem: ".$linkdate. " Diff: ".$diff."<br>";
if ($diff < 3)
{
fwrite($lfh, $green);
}
else if ($diff < 8)
{
fwrite($lfh, $yellow);
}
else
{
fwrite($lfh, $none);
}
$i++;
}
flock($lfh, LOCK_UN);
fclose($lfh);
}
// read file into array
$data = file($filename) or die("Could not read file!");
// loop through array and print each line
// Let's declare the script element according to X(HT)ML rules...
echo '<script type="text/javascript">' . "\n";
echo '// <![CDATA[' . "\n";
echo ' var arrLines = new Array();' . "\n";
// Let's go through $data starting with element 0 to element lenght - 1
for($intL = 0; $intL < count($data); $intL++)
{
// Let's add backslahes to quotes (" => \", ' => \') and backslashes (\ => \\)
$strLine = addslashes($data[$intL]);
// Let's replace the actual \n and \r to their representation...
// We don't want a carriage return at the end of the line before putting the quote !
$strLine = str_replace("\n", '\n', $strLine);
$strLine = str_replace("\r", '\r', $strLine);
// Let's print each line using this syntax :
// arrLines[Position of the element] = "contents of the line with extra backslashes and transformed carriage returns";
printf((' arrLines[%s] = "%s";' . "\n"), $intL, $line);
}
// Let's declare the closing part of the script element...
echo '// ]]>' . "\n";
echo '</script>' . "\n";
// print file contents
echo "-- ALL DONE --<br>";
?>
end of html
</script>
</BODY>
</HTML>
RESULT:
start of html ' . "\n"; // print file contents echo "-- ALL DONE --
"; ?> end of html