I have a folder with multiple .js files(I have the file number count in a variable)
Is it possible to "include" all the js scripts using a for loop?
Something like:
for(i = 0; i <= file_count; i++) {
include('scriptname' + i)
}
Thanks
I have a folder with multiple .js files(I have the file number count in a variable)
Is it possible to "include" all the js scripts using a for loop?
Something like:
for(i = 0; i <= file_count; i++) {
include('scriptname' + i)
}
Thanks
declare a php array inside a php file (call it "file_names.php") and write names of all .js files
<?php
$file_array=array('file1.js','file2.js')
?>
then include the php file in your desired page and iterate over the array inside your page's HTML header tag
include('file_names.php')
<?php foreach($file in $file_array){ ?>
<script src='<?php echo $file; ?>'></script>
<?php } ?>