In a php file, I have a function that finds the most recent txt file and sets it as a variable $filesb
to be parsed out:
$dir = "../geo-05/Hassayampa/";
if($dir) chdir($dir);
$filesb = glob('{Graph}*.{txt}', GLOB_BRACE);
usort($filesb, create_function('$e, $f', 'return filemtime( $f ) - filemtime ( $e );')
);
for ($i = 0; $i < $show; ++$i)
$dir.$filec = $filesb[$i];
further down the page I have my Highcharts graph in <script>
tags. In the $.get
tag I've inserted:
$.get('<?php echo $filesb[0]?>', function(data){
but the data from the array $filesb
does not graph. Does the javascript function not recognize the array? It does work when I point to the file directly:
$.get('http://www.geoinc.org/monitor/SiteData/Data/geo-05/Hassayampa/Graph_telemetry_140626.txt', function(data){
The reason I don't have it pointing at the file directly is because the file name changes, so if I set it to be $filesb
it will always find the most recent file. I apologize if I am unclear, I am new to coding.