Skip to content

Instantly share code, notes, and snippets.

@Aleksandr-ru
Created May 11, 2016 08:23
Show Gist options
  • Save Aleksandr-ru/d5f6797638137fcbe33cbb65f36ceeb0 to your computer and use it in GitHub Desktop.
Save Aleksandr-ru/d5f6797638137fcbe33cbb65f36ceeb0 to your computer and use it in GitHub Desktop.
<?php
/**
* Проверяет наличие строковых ключей в массиве
* @param array $arr
* @return bool
* @link http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
*/
function is_assoc($arr)
{
if(!is_array($arr)) {
trigger_error("Argument should be an array for is_assoc", E_USER_WARNING);
return FALSE;
}
return count(array_filter(array_keys($arr), 'is_string')) > 0;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment