1// return true if array is associative
2function checkAssoc($array) {
3 $nonAssociative = count(array_filter(array_keys($array), 'is_string')) === 0;
4 if ($nonAssociative) {
5 return false;
6 } else {
7 return true;
8 }
9}
10// Example
11$array = ["el1" => 1, "el2" => 2, "el3" => 3];
12checkAssoc($array);
13// bool(true)