<p>PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fairly efficient way to check if an array <em>&quot;is a list&quot;</em> (contains only numeric keys starting from 0)?</p>
<p>Basically, I want to be able to differentiate between this:</p>
<pre><code>$sequentialArray = [
    'apple', 'orange', 'tomato', 'carrot'
];
</code></pre>
<p>and this:</p>
<pre><code>$assocArray = [
    'fruit1' =&gt; 'apple',
    'fruit2' =&gt; 'orange',
    'veg1' =&gt; 'tomato',
    'veg2' =&gt; 'carrot'
];
</code></pre>

Unless PHP has a builtin for that, you won't be able to do it in less than O(n) - enumerating over all the keys and checking for integer type. In fact, you also want to make sure there are no holes, so your algorithm might look like:
```
```
for i in 0 to len(your_array):
    if not defined(your-array[i]):
        # this is not an array array, it's an associative array :)
```
```
But why bother? Just assume the array is of the type you expect. If it isn't, it will just blow up in your face - that's dynamic programming for you! Test your code and all will be well...