Last active
December 30, 2015 03:58
-
-
Save amirbehzad/de7be58b5d39c483e134 to your computer and use it in GitHub Desktop.
PHP: How to ensure a variable is an Array, and it is not empty
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 | |
// returns True if the given $var is an Array, and it is not empty; | |
// otherwise, False. It does not gives an error if the given $var | |
// is not an Array, however, it returns False. | |
function isNonEmptyArray($var) { | |
return !empty(@reset($var)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is basically a shorthand for: