I encountered this warning message when I am making my own plugin in wordpress. I am using for each loop in php where I have arrays of array as its parameter.
It was not hard for me to found the reason for the message Warning: Invalid argument supplied for foreach() in….
I noticed it is working well when the arrays are not empty therefore I get that Warning message whenever I get an empty array.
Got a warning message from php after running my php wordpress plugin using foreach loop. And the Warning message is Warning: Invalid argument supplied for foreach() in….
Add condition before using foreach if array inside the foreach is empty or not.. I used count to check if the array is empty or not.
foreach($records as $record)
Hope this help. Thanks!