<?php
function isAssoc(array $array){
$keys = array_keys($array);
return array_keys($keys) !== $keys;
}
//using
var_dump(isAssoc(['test'=>'associative','1'=>'integer'])); // true
var_dump(isAssoc(['test','integer','associative'])); // false
<?php
function isAssoc($a) {
foreach(array_keys($a) as $key)
if (!is_int($key)) return true;
return false;
}
//using
var_dump(isAssoc(['test','integer','associative'])); // false
var_dump(isAssoc([1=>'test',2=>'integer',100=>'associative'])); // false
Валидаторы
PHP