如何检查PHP数组是关联数组仍是顺序数组? - How to check if PHP array is associative or sequential?

问题:

PHP treats all arrays as associative, so there aren't any built in functions. PHP将全部数组视为关联数组,所以没有任何内置函数。 Can anyone recommend a fairly efficient way to check if an array contains only numeric keys? 谁能推荐一种至关有效的方法来检查数组是否仅包含数字键? 数组

Basically, I want to be able to differentiate between this: 基本上,我但愿可以区分如下二者: app

$sequentialArray = array('apple', 'orange', 'tomato', 'carrot');

and this: 和这个: 函数

$assocArray = array('fruit1' => 'apple', 
                    'fruit2' => 'orange', 
                    'veg1' => 'tomato', 
                    'veg2' => 'carrot');

解决方案:

参考一: https://stackoom.com/question/j6m/如何检查PHP数组是关联数组仍是顺序数组
参考二: https://oldbug.net/q/j6m/How-to-check-if-PHP-array-is-associative-or-sequential
相关文章
相关标签/搜索