Created
April 7, 2014 16:14
-
-
Save 2ndkauboy/10023362 to your computer and use it in GitHub Desktop.
A handy function to check for an array if all key do exist and none of them has an empty value
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
/** | |
* Check an array if all key to exists and none of them has an empty value | |
* | |
* @param array $array The array. | |
* @param array $keys The searched keys. | |
* @return boolean returns true, if all keys existed in the array and none of them had empty values | |
*/ | |
function array_keys_not_empty($keys, $array){ | |
foreach($keys as $key){ | |
if(!array_key_exists($key, $array) || empty($array[$key])){ | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment