php check array is not associative
count(array_filter(array_keys($array), 'is_string')) === 0
php check array is not associative
count(array_filter(array_keys($array), 'is_string')) === 0
php array is associative
function isAssoc(array $arr) { if (array() === $arr) return false; return array_keys($arr) !== range(0, count($arr) - 1); } var_dump(isAssoc(['a', 'b', 'c'])); // false var_dump(isAssoc(["0" => 'a', "1" => 'b', "2" => 'c'])); // false var_dump(isAssoc(["1" => 'a', "0" => 'b', "2" => 'c'])); // true var_dump(isAssoc(["a" => 'a', "b" => 'b', "c" => 'c'])); // true
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us