Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4615562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:51:28+00:00 2026-05-22T01:51:28+00:00

Today i have a problem with my script, my script should search for (.css

  • 0

Today i have a problem with my script, my script should search for (.css files)

I’ve used a code to:

  1. Search for all subfolders in a root folder
  2. Make all paths of subfolders in an array
  3. 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:51:29+00:00Added an answer on May 22, 2026 at 1:51 am

    Change this:

    $path[] = $dir;
    foreach($path as $dirname){
        $add = glob($dirname . '/*.css');
        foreach($add as $file){
    

    to this:

    $path[] = $dir;
    var_dump($path);
    foreach($path as $dirname){
        $add = glob($dirname . '/*.css');
        var_dump($add);
        foreach($add as $file){
    

    We don’t know which line 131 is, so I don’t know which foreach fails.

    (I’m guessing the 2nd, because the first is practically forced to array by $path[] = ..)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with this code: NSDate *today = [[NSDate alloc] init]; if
I'm familiar with using NSLocalizedString() to localize strings, but the problem I have today
I've run on a little problem today: I have a JS drop down menu
Hi everyone my problem today is I have a couple of buttons that slide
Today I ran into the following problem with NUnit. I have a class, that
Today I faced a strange problem in C#. I have an ASP.NET page where
So I came across an interesting problem today. We have a WCF web service
today I've been working on loading dynamic javascript code (files). The solution I use
I have used this datepicker for quite awhile in this specific code. I made
I have a script that I completed a week ago, without any problem or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.