Skip to content

Instantly share code, notes, and snippets.

@farico
Created May 27, 2010 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farico/415741 to your computer and use it in GitHub Desktop.
Save farico/415741 to your computer and use it in GitHub Desktop.
<?php
/**
* isset( $var['a'], $var['b'] ) shortcut: array_has( $var, 'a', 'b' );
*/
function array_has( &$var ) {
$args = func_get_args();
if ( ! empty( $args ) && is_array( $args[0] ) && count( $args ) > 1 ){
$count_args = count( $args );
for ( $i = 1; $i < $count_args; $i++ ) {
if ( ! isset( $var[$args[$i]] ) ) {
return false;
}
}
return true;
}
return false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment