Last active
February 4, 2016 13:01
-
-
Save robi09/fab8f7079f7f94efea66 to your computer and use it in GitHub Desktop.
Check if array key exists and if it is 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
if(!function_exists('array_key_check')) { | |
function array_key_check($key = NULL, $array = NULL) { | |
if($key == NULL or $array == NULL) { | |
return NULL; | |
} else { | |
if(array_key_exists($key, $array)) { | |
if(!empty($array[$key])) { | |
return TRUE; | |
} | |
} | |
} | |
} | |
} | |
//Use example: | |
if(array_key_check(R_MPRE . 'row_featured', $row)) { | |
echo '<i class="extra fa fa-check"></i>'; | |
} else { | |
echo '<i class="fa fa-check"></i>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment