Hi there,
HELP!!!
???
I am trying to filter some files in my site directories so i can save the .js files and .css files in two separate arrays. The thing is its not displaying. I got it to show me something when i removed the closing bracket for " foreach($directories as $dirs){ " to the spot before else.
Below is the code:
PLEASE HELP!!!
function get_system_dir_paths($dir){
$scripts = array();
$styles = array();
if(is_dir($dir)){
$directories = scandir($dir);
foreach($directories as $dirs){
if(is_dir($dirs)){
if($dirs === '..' || $dirs === '.') continue;
else{
$files = scandir($dirs);
}
}
}
//Adds the correct file type to the correct array
foreach($files as $file){
if(strpos($file, '.js')){ //if .js in file then add to $scripts
$scripts[] .= $files;
}
else if(strpos($file, '.css')){ //if .css in file then add to $styles
$styles[] .= $files;
}
else
continue;
}
}
else{
print “NO DIRECTIOR FOUND”;
}
//$files = array_unique($files);
foreach($scripts as $script){
echo $script ."
";
}
echo "<br />";
foreach ($styles as $style){
echo $style . "<br />";
}
}
?>