<?php
if (is_array($array) || is_object($array))
{
foreach ($array as $row)
{
...
}
}
?>
$array = ['dog', 'cat', 'lion'];
if (!empty($array) && isset($array) && is_array($array) {
//loop
foreach ($array as $values) {
echo $values;
}
}