PHP Warning: Variable passed to each() is not an array or object


PHP Warning: Variable passed to each() is not an array or object in /home/functions.php on line 23

Error type: warning


You try to use each, but instead of going through the loop, you just receive a warning.

Sample Code:

while (list($key, $val) = each ($myvar))
echo $key.’ ‘;


You try to use the each() function with a null, integer or string variable (or generally not an array or object). This might be caused by an uninitialized variable you try to use with each();


Make sure the variable you try to pass exists and is not null first. You should also make sure you didn’t misspell the variable name (if you try to use a variable that has not been initialized you get the same warning).

You should try to use function is_array($array) to make sure the variable passed is indeed an array.

3 Responses

  1. server servers Says:

    Wow! In the end I got a website from where I be capable
    of in fact get valuable facts concerning my study and knowledge.

  2. southasian Says:

    Is there any fix? This caused due newer version of php 5.

  3. cool site Says:

    I take pleasure in, lead to I discovered exactly what I was taking a look for.
    You’ve ended my four day lengthy hunt! God Bless you man. Have a nice day. Bye

Leave a Reply

Your email address will not be published. Required fields are marked *

Security question: *