title: How to check if variable is array?... or something array-like
body: <p>I want to use a <code>foreach</code> loop with a variable, but this variable can be many different types, <code>NULL</code> for example.</p>
  
  <p>So before <code>foreach</code> I test it:</p>
  
  <pre><code>if(is_array($var)){
    foreach($var as ...
  </code></pre>
  
  <p>But I realized that it can also be a class that implements <code>Iterator</code> interface. Maybe I am blind but how to check whether the class implements interface? Is there something like <code>is_a</code> function or <code>inherits</code> operator? I found <code>class_implements</code>, I can use it, but maybe there is something simpler?</p>
  
  <p>And second, more important, I suppose this function exist, would be enough to check if the variable <code>is_array</code> or "implements <code>Iterator</code> interface" or should I test for something more?</p>