It often happens to me to handle data that can be either an array or a null variable and to feed some foreach with these data.
foreach
$values = get_val
Use is_array function, when you will pass array to foreach loop.
if (is_array($your_variable)) { foreach ($your_variable as $item) { //your code } }