0

I am getting this error in PHP / ZF2:

 Warning: Invalid argument supplied for foreach()

But I can render the form elements. Why I am getting this error in Zend framework 2 and How to resolve this error?

user3428816
  • 1,241
  • 3
  • 16
  • 32

1 Answers1

1

probably you are trying to loop throught a non-object or non-array variable

in case $foo should be an object:

if(is_object($foo)){
   foreach($foo as $element){
       // ...
   }
}

in case $foo should be an array:

if(is_array($foo)){
   foreach($foo as $element){
       // ...
   }
}

hope this helps

ponciste
  • 2,231
  • 14
  • 16