Created
April 8, 2019 11:12
-
-
Save itsmikita/197ddcbc542ff9f2c5547ff5349388e4 to your computer and use it in GitHub Desktop.
Missing PHP helper methods __keys_exist( $keys, $array ) and __any_keys_exist( $keys, $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
/** | |
* Check ANY keys exist in an array | |
* | |
* @param $keys | |
* @param $array | |
*/ | |
function __any_keys_exist( $keys, $array ) | |
{ | |
foreach( $keys as $key ) { | |
if( isset( $array[ $key ] ) { | |
return true; | |
} | |
} | |
return false; | |
} |
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
/** | |
* Check ALL keys exist in an array | |
* | |
* @param $keys | |
* @param $array | |
*/ | |
function __keys_exist( $keys, $array ) | |
{ | |
foreach( $keys as $key ) { | |
if( ! isset( $array[ $key ] ) { | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment