Created
November 21, 2014 10:35
-
-
Save Zeronights/6d68835e4b9a8476bd6a to your computer and use it in GitHub Desktop.
[php5.6] array_keys_exist
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 | |
if (!function_exists('array_keys_exist')) { | |
/** | |
* Checks if given keys or indexes exist in the array. | |
* | |
* @author Ozgur Giritli <ozgur@zeronights.com> | |
* | |
* @param array $array Array to check keys against. | |
* @param mixed $keys Key to check existance of. | |
* @param mixed $keys,... Additional keys to check existance of. | |
* @return boolean | |
*/ | |
function array_keys_exist($array, ...$keys) { | |
return count(array_intersect_key(array_flip($keys), $array)) === count($keys); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment