Skip to content

Instantly share code, notes, and snippets.

@dapepe
Created February 4, 2014 09:14
Show Gist options
  • Save dapepe/8800413 to your computer and use it in GitHub Desktop.
Save dapepe/8800413 to your computer and use it in GitHub Desktop.
Checks if an array is associative or numeric
<?php
/**
* Checks if an array is associative or numeric
*
* @param array $arr
*/
function isAssoc($arr) {
return is_array($arr) ? (array_keys($arr) !== range(0, count($arr) - 1)) : false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment