Earlier I had posted my problem with getting a single variable to javascript. It was resolved using var jstest='<?php echo $test?>';.....I now need to get an array to an equivalent array in javascript and everything I try fails! I am a newbie to php but everything I try fails.
The code below has the array $data I would like to pass to js. The code may not be perfect but it is echoing the values. Please, I would like an example of how to do this. Thanks in advance. Bob
<?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
foreach ($data as $line)
{
echo $line,"<br>";
}
// print file contents
echo "-- ALL DONE --<br>";
?> :mad: