Jump to content

Invalid argument supplied for foreach()


c4n10

Recommended Posts

Hello all,

 

I am working on a site which is returning "Warning: Invalid argument supplied for foreach()"

 

The function that is returning the warning is:

 

function currentworkers() {
                $currentworkers = 0;
                if (!($currentworkers = getCache("pool_workers"))) {
                        $uwa = $this->workerhashrates();
                        foreach ($uwa as $key => $value) {
                                if ($value > 0)
                                        $currentworkers += 1;                  $
                        }
                        setCache("pool_workers", $currentworkers, 1800);
                }
                return $currentworkers;
	}

 

 

Any help is greatly appreciated, thanks!!!

Link to comment
https://forums.phpfreaks.com/topic/275991-invalid-argument-supplied-for-foreach/
Share on other sites

It looks as though $this->workerhashrates() is not returning an array

 

You are absolutely correct, turns out the backend code we are using hasn't been writing to the db so there has been no info to retrieve so it is returning an empty array, thank you for the help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.