Skip to content

Instantly share code, notes, and snippets.

@Zeronights
Created November 21, 2014 10:35
Show Gist options
  • Save Zeronights/6d68835e4b9a8476bd6a to your computer and use it in GitHub Desktop.
Save Zeronights/6d68835e4b9a8476bd6a to your computer and use it in GitHub Desktop.
[php5.6] array_keys_exist
<?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