问题:
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: 基本上,我希望能够区分以下两者:
$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
来源:oschina
链接:https://my.oschina.net/u/3910071/blog/4254638