Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Created April 7, 2014 16:14
Show Gist options
  • Save 2ndkauboy/10023362 to your computer and use it in GitHub Desktop.
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
/**
* 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