Skip to content

Instantly share code, notes, and snippets.

@DaveyJake
Last active February 8, 2022 03:11
Show Gist options
  • Save DaveyJake/5b79680190dc478a9b57d079c8ca2a5f to your computer and use it in GitHub Desktop.
Save DaveyJake/5b79680190dc478a9b57d079c8ca2a5f to your computer and use it in GitHub Desktop.
[PHP] Check For Associative Array
<?php
/**
* Helper function that checks an array for string keys aka an associative array.
*
* @author Davey Jacobson <daveyjake21 [at] geemail [dot] com>
*
* @param array $array Array to check.
*
* @return bool True if associative. False if not.
*/
function is_array_associative( array $array ) {
return count( array_filter( array_keys( $array ), 'is_string' ) ) > 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment