title: How to check for arrayness in PHP?
body: <p>The best I could come up is </p>
  
  <pre><code>function is_array_alike($array) {
    return is_array($array) || (is_object($array) &amp;&amp; $array instanceof ArrayAccess &amp;&amp; $array instanceof Traversable &amp;&amp; $array instanceof Serializable &amp;&amp; $array instanceof Countable);
  }
  </code></pre>
  
  <p>Ugh. Is there something more pretty?</p>
  
  <p>Edit: the test for <code>is_object</code> seems unnecessary. I have added a section to the instanceof PHP manual about that.</p>