Today i have a problem with my script, my script should search for (.css files)
I've used a code to:
- Search for all subfolders in a root folder
- Make all paths of subfolders in an array
- by using foreach(){glob....}, the script should found all paths of css files
Here is my code :
$path = '';
$stack[] = $dir;
while ($stack) {
$thisdir = array_pop($stack);
if ($dircont = scandir($thisdir)) {
$i=0;
while (isset($dircont[$i])) {
if ($dircont[$i] !== '.' && $dircont[$i] !== '..') {
$current_file = "{$thisdir}/{$dircont[$i]}";
if (is_dir($current_file)) {
$path[] = "{$thisdir}/{$dircont[$i]}";
$stack[] = $current_file;
}
}
$i++;
}
}
}
$path[] = $dir;
foreach($path as $dirname){
$add = glob($dirname . '/*.css');
foreach($add as $file){
$code = file_get_contents($file);
$code_arab = arabicer($code);
file_put_contents($file,$code_arab);
}
}
When i start my script i found an waning message:
Warning: Invalid argument supplied for foreach() in /home/u274517531/public_html/libs/functions.php on line 131
I'm sure my array is not empty.
So, anyone can help me how to solve this problem ?
Thanks.