Last active
February 8, 2022 03:11
-
-
Save DaveyJake/5b79680190dc478a9b57d079c8ca2a5f to your computer and use it in GitHub Desktop.
[PHP] Check For Associative Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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