Language

How To Fix Invalid argument supplied for foreach() In Laravel 5.4

Date 13 May, 2017

Details :

1. If Array is Null or  Empty you will get a error Invalid argument supplied for foreach()

    so just check the Array have a values or not

2. Just put  foreach like below block of code. In below code we check $values

if (is_array($values) || is_object($values))
{
    foreach ($values as $value)
    {
       do your stuff 
    }
}