Skip to content

Instantly share code, notes, and snippets.

@rafasashi
Created June 1, 2015 11:45
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 rafasashi/0d3ebadf08b8c2976a9d to your computer and use it in GitHub Desktop.
Save rafasashi/0d3ebadf08b8c2976a9d to your computer and use it in GitHub Desktop.
function get_array_value($array=array(), $path=array()){
foreach($path as $key) {
if(isset($array[$key])){
$array=$array[$key];
}
else{
$array=NULL;
break;
}
}
return $array;
}
function custom_isset($array=array(), $path=array()){
$isset=true;
if(is_array($array)&&is_null(get_array_value($array, $path))){
$isset=false;
}
return $isset;
}
function is($array=array(), $path=array()){
$is=false;
if(is_array($array)){
$array_value=get_array_value($array, $path);
if(is_bool($array_value)){
$is=$array_value;
}
}
return $is;
}
**Example**
$status=[];
$status['updated']=true;
if(is($status,array('updated'))){
//do something...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment