PHP what is the best way to handle a variable that may not be set?
<p>I have a foreach loop, that will loop through an array, but the array may not exist depending on the logic of this particular application.</p>

<p>My question relates to I guess best practices, for example, is it ok to do this:</p>

<pre><code>if (isset($array))
{

    foreach($array as $something)
    {
        //do something
    }
}
</code></pre>

<p>It seems messy to me, but in this instance if I dont do it, it errors on the foreach. should I pass an empty array?? I haven't posted specific code because its a general question about handling variables that may or may not be set. </p>
