Created
June 23, 2016 22:36
-
-
Save acapps/64b941cca49828720943dbd88b91a322 to your computer and use it in GitHub Desktop.
All keys exist in array.
This file contains hidden or 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
//The values in this arrays contains the names of the indexes (keys) that should exist in the data array | |
$required = array('key1', 'key2', 'key3' ); | |
$data = array( | |
'key1' => 10, | |
'key2' => 20, | |
'key3' => 30, | |
'key4' => 40 | |
); | |
if(count(array_intersect_key(array_flip($required), $data)) === count($required)) { | |
//All required keys exist! | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment