Prevent a PHP Warning "Invalid argument supplied for foreach()"