I made simple page with slides and wanted to load it every 5 sec when JS timer looping.
I add comments which describe where the problem is. PHP scan dir only when page loads and does not notice changes in the folder in timer.
here's the code:
<script type="text/javascript">
......
var main_timer = setInterval(function(){slideTimer()}, 5000);
......
function slideTimer() {
......
<?php
//This PHP code need to be looped inside the timer
$array = array();
$array = array_slice(scandir('strony'), 2);
$js_array = json_encode($array);
?>
........
pages = <?php echo $js_array; ?>;
........
........
}
</script>